Go to page Previous  1 ... 37, 38, 39, 40, 41  [ 816 posts ]  Reply to topicPost new topic 
Coding Help, Questions and Issues relating to coding
Author Message
 [us]
 Post subject: Re: Coding Help
PostPosted: Wed Feb 15, 2017 6:53 pm 
User avatar
Member
I solved the problem

I forgot to account the Horizontal speed of the player when checking for collision.

Code:
//Horizontal Collision
slope_max = 10
if !place_meeting(x+sign(Hsp),y,Solid)
{
 for (cd=0;!place_meeting(x+Hsp,y+cd,Solid) && cd<=abs(slope_max);cd+=1;)
 {
   if !place_meeting(x+Hsp,y+cd,Solid) and place_meeting(x+(Hsp),y+slope_max,Solid)//Right Here
   y+=cd;
 }

}

if place_meeting(x+Hsp,y,Solid)
{
    cu = 0;
    while ((place_meeting(x+Hsp,y-cu,Solid) && cu <= abs(slope_max))) cu += 1;
    if place_meeting(x+Hsp,y-cu,Solid)
    {
        while (!place_meeting(x+sign(Hsp),y,Solid)) x+=sign(Hsp);
        Hsp = 0;
    }
    else
    {
        y-=cu;
    }
}

x += Hsp;


Kinda knew it was something as simple as that ><
Hills now behave almost exactly like they did in Yoshi's Island :P

 
Top
Offline 
 User page at mfgg.net
 
 [es]
 Post subject: Re: Coding Help
PostPosted: Tue Mar 28, 2017 12:49 am 
User avatar
I'm just a little adorable kitty :3
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

Well, I'm on a hurry for this.

I need a code to make an object change its alpha gradually as you approach it with x object.

_________________
Image ImageImageImageImageImageImage Image
~ Supernova / Drawerkirby (2) / Gato / Neweegee (2) (3) ~
"shy guys are wall plugs confirmed" - Vitiman on Club Saturn Ex
Image
 
Top
Offline 
 User page at mfgg.net
 
 [zz]
 Post subject: Re: Coding Help
PostPosted: Tue Mar 28, 2017 6:21 am 
User avatar
Member
[*]
Gatete wrote:
Well, I'm on a hurry for this.

I need a code to make an object change its alpha gradually as you approach it with x object.


Code:
var targetobject = <insert_x_object_here>
var maxdist = <insert_how_close_object_has_to_be_to_start_appearing>
image_alpha =  min(max(1 - (point_distance(x,y,targetobject.x,targetobject.y)/maxdist),0),1);

 
Top
Offline 
 
 
 [us]
 Post subject: Re: Coding Help
PostPosted: Wed Apr 19, 2017 7:15 am 
User avatar
"I am one valuable card"
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
I really put my effort on "pulling" effect, but I can't get the hang out of it. Even though, it is a tough code for me to deal with on "ground-only", "pull from left or right" , "cancellation to crouch" , and "the range of the pull-able block".

I can gladly put the original code I've put down, but I deleted it just for the sake of the ease of frustration. Here is my code for my character:

Code:
///Logistics of the Raccoon!

//Get the player's input
key_right = keyboard_check(vk_right);
key_left = -keyboard_check(vk_left);
key_up = keyboard_check(vk_up);
key_down = keyboard_check(vk_down);
key_jump = keyboard_check_pressed(ord('Z'));
key_jump_held = keyboard_check(ord('Z'));

//React to inputs
if pull = false
{
if pullhold = false
{
if duck = false  // If not ducking
move = key_left + key_right;
}
}

hsp = move * movespeed;
if climb = false // If not in ropes...
if (vsp < 10) vsp += grav;

//--Duck--

if grounded = true && bounce_attack = false // If on ground but, not bouncing
{
if key_down  && place_meeting(x,y+1,obj_wall)
{
duck = true
move = 0
bounce_able = false
}
else
{
duck = false
bounce_able = true
}
}

//--Jump--
if (place_meeting(x,y+1,obj_wall))
{
if grounded = true
{
if bounce_attack = false && (key_jump) && climb = false && chargeon = 0 && attack = false && pull = false{
 grounded = false
vsp = -jumpspeed
jumpland = true
}

//--Tail Attack--


if keyboard_check_pressed(ord('X')) && attack = false && !key_down && !place_meeting(x+1,y,obj_pushblock_trigger) && !place_meeting(x-1,y,obj_pushblock_trigger)
{
attack = true
sprite_index = spr_rac_spin
image_speed = 0.4
instance_create(x,y,obj_tailmask)
audio_play_sound(snd_player_spin,1,0)
}


if !keyboard_check(ord('X')) && attack = false
{
if chargeon = true && chargetime < 30
{
chargeon = false
chargetime = 0
charge = 0
}
else if chargeon = true && chargetime >= 30
{
attack = true
sprite_index = spr_rac_chargespin
image_speed = 0.4
image_index = 0
instance_create(x,y,obj_tailmask)
audio_play_sound(snd_player_spin,1,0)
}
}

}
}

else
grounded = true

//---Charging Process---
if chargeon = true && chargeready = 0 && chargetime != 30
{
chargetime += 0.5
}
else if chargeon = true && chargetime >= 30
{
chargetime = 30
chargeready = 1
}

//--Jumping Variable Check--
if (vsp < 0) && (!key_jump_held) vsp = max(vsp,-jumpspeed/4.5)

//--Bouncing Ability--
if keyboard_check(ord('X')) && key_down && bounce_able = true && !place_meeting(x,y-3,obj_wall)
{
bounce_attack = true
chargeon = false
}
else
{
bounce_attack = false
}
//Horizontal Collision
if (place_meeting(x+hsp,y,obj_wall))
{
    while(!place_meeting(x+sign(hsp),y,obj_wall))
    {
        x += sign(hsp);
    }
    hsp = 0;
}
if climb = false && chargeon = false
x += hsp;

//Vertical Collision
if (place_meeting(x,y+vsp,obj_wall))
{
    while(!place_meeting(x,y+sign(vsp),obj_wall))
    {
        y += sign(vsp);
    }
   
    {
     if bounce_attack = true && (vsp > 0) &&  place_meeting(x,y+1,obj_wall)// If Bouncing and in Air
    {
    sprite_index = spr_rac_bounced;
    vsp = -vsp
    audio_play_sound(snd_player_bounce,1,0)
    } 
    else vsp = 0; 
   
  if jumpland = true && place_meeting(x,y+1,obj_wall) && bounce_attack = false
    {
    jumpland = false
    if climb = false
    audio_play_sound(snd_player_land,1,0)
    }
    }
}
y += vsp;

//Animation
if climb = false // If not in a climb state
{
if pull = false
{
if attack = false // If not attacked
{
if chargeon = false
{
if (move!=0) image_xscale = move;
if (place_meeting(x,y+1,obj_wall))
{
    if (move!=0)
    {
   if bounce_attack = true and place_meeting(x,y+1,obj_wall)
    sprite_index = spr_rac_bounced;
    else
    sprite_index = spr_rac_walk;
    image_speed = 0.15;
    }
    else
    {
    if duck = true {sprite_index = spr_rac_duck image_speed = 0;}
    else
    if bounce_attack = true and place_meeting(x,y+1,obj_wall)
    sprite_index = spr_rac_bounced;
    else
    sprite_index = spr_rac_stand;
    image_speed = 0;
    }
}
else

    if (vsp < 0) or (vsp > 0)
    {
    if bounce_attack = true
    sprite_index = spr_rac_bounce
    else
    sprite_index = spr_rac_jump
    }
}
}
}
}
if hit = true // If attacked or hit
{
if image_xscale = 1
{
if hurt = true
{
if !place_meeting(x-4,y,obj_wall)
x -= 4
hurt = false
}
}
else if image_xscale = -1
{
if hurt = true
{
if !place_meeting(x+4,y,obj_wall)
x += 4
hurt = false
}
}
}
//Prevent from going outside the room (on the side)
if x < 3 x = 3
if x > room_width-3 x = room_width-3
if y < -5 y = -5   

// Mask Change
if bounce_attack = true && duck = false  // Climb {SAME} Mask
mask_index = spr_mask
else if duck = true && bounce_attack = false // Crouch Mask
mask_index = spr_mask_crouch
else if duck = false && bounce_attack = false  // Normal Mask
mask_index = spr_mask


//--Climb--
if (collision_line(x, bbox_top, x, bbox_bottom - 8, obj_rope, false, false)) &&  keyboard_check_pressed(vk_up)
{
climb = true //  Triggers the activation to climb
x = obj_rope.x+8
}

if (climb) // If he is on ladder or climable object
{
    hsp = 0;
    vsp = 0;
    jumpable = false
if !keyboard_check(vk_up) || !keyboard_check(vk_down)
{
image_speed = 0
}
sprite_index = spr_rac_climb


if climbmovement = true
{
if keyboard_check(vk_up)
{
if place_free(x,y-2)
image_speed = 0.15;
vsp-=2
}

if keyboard_check(vk_down)
{
if place_free(x,y+2)
image_speed = 0.15;
vsp+=2
}
if (key_up and !collision_line(x, bbox_top, x, bbox_bottom - 8, obj_rope, false, false))
    or (!collision_line(x, bbox_top, x, bbox_bottom, obj_rope, false, false))
    {
        climb = false;
        jumpable = true;
       
    }
    }
   
if (key_jump)
{
vsp = -jumpspeed
jumpland = true
climb = false   
}
}

if global.invincibility = 1
alarm[5] = 1;


Situations:
*Border Transition (Like Mega Man)
*Pulling and (Pushing?) Block

I'm only just a rookie of figuring things out like this...

_________________
Image
Image

Image
NNID: SonicZetrex
User: SonicZetrx


Old Drawing Banners

Spoiler:

Things I support/others

Spoiler:


My favorite theme:

 
Top
Offline 
 User page at mfgg.net
 
 [tn]
 Post subject: Re: Coding Help
PostPosted: Tue May 16, 2017 9:45 am 
User avatar
They Seeme Rawlin' Dey Hatein'
Member
[*]
[*]
So, i'm trying to Make a circular Transition, i'm trying to do this an work from scratch, with Game maker 8.

So, i've tried the animated sprite, but it keeps animating, even when i put image_speed=0 in Animation End Event.
Is there a way to solve it?

_________________

 
Top
Offline 
 User page at mfgg.net
 
 [fi]
 Post subject: Re: Coding Help
PostPosted: Tue May 16, 2017 12:40 pm 
User avatar
:3c
Member
[*]
[*]
[*]
[*]
[*]

How exactly are you making the circular transition? With an animated sprite? If that's the case, try:

Code:
///Animation end event
image_speed = 0;
image_index = sprite_get_number(sprite_index)-0.01;

_________________
YouTube | Steam | Twitter

My signature is very empty now that I've removed the advertising. :(
 
Top
Offline 
 User page at mfgg.net
 
 [es]
 Post subject: Re: Coding Help
PostPosted: Tue May 16, 2017 2:19 pm 
User avatar
I'm just a little adorable kitty :3
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

This might help you!

This does not make use of sprites at all, it uses the draw_circle function

_________________
Image ImageImageImageImageImageImage Image
~ Supernova / Drawerkirby (2) / Gato / Neweegee (2) (3) ~
"shy guys are wall plugs confirmed" - Vitiman on Club Saturn Ex
Image
 
Top
Offline 
 User page at mfgg.net
 
 [tn]
 Post subject: Re: Coding Help
PostPosted: Tue May 16, 2017 4:09 pm 
User avatar
They Seeme Rawlin' Dey Hatein'
Member
[*]
[*]
CatoNator wrote:
How exactly are you making the circular transition? With an animated sprite? If that's the case, try:

Code:
///Animation end event
image_speed = 0;
image_index = sprite_get_number(sprite_index)-0.01;

Yes, i used to run that, i scrapped that method before posting, but thanks anyways.


Gatete wrote:
This might help you!

This does not make use of sprites at all, it uses the draw_circle function

Yes, Thanks. :thumbsup:

_________________

 
Top
Offline 
 User page at mfgg.net
 
 [ie]
 Post subject: Re: Coding Help
PostPosted: Thu May 18, 2017 2:38 am 
User avatar
thanks, neweegee!
Member
[*]
[*]
[*]
[*]
[*]

[*]
I need some code for ground pounding in GMStudio please! :confused:

_________________
legit best song ever


my youtube:
https://www.youtube.com/channel/UC7Pu2NplrfCUbTxE_zyHITQ
 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: Coding Help
PostPosted: Tue Jul 25, 2017 1:22 pm 
User avatar
¿
Good At French
[*]
[*]
[*]
[*]
I know this is stupid, but could anyone tell how to make a sprite appear on top of another sprite instead of below?

Edit: It's in gamemaker 8.1

_________________
"90 percent of everything is crap" - Some guy named Theodore
 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: Coding Help
PostPosted: Wed Jul 26, 2017 4:04 pm 
User avatar
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
littlelum wrote:
I know this is stupid, but could anyone tell how to make a sprite appear on top of another sprite instead of below?

Edit: It's in gamemaker 8.1


Can you provide a screenshot of what is actually happening and what is expected?

I need some code for ground pounding in GMStudio please! :confused:


If you are able to make your character jump, then a ground pound should simply be the reverse. If your player is in the air and a 'button' is pressed, the characters 'vertical speed' should move down. Gravity should not be applied to the 'vertical speed' when doing a ground pound (unless you want I suppose).

 
Top
Offline 
 
 
 [us]
 Post subject: Re: Coding Help
PostPosted: Thu Jul 27, 2017 12:20 pm 
User avatar
¿
Good At French
[*]
[*]
[*]
[*]
Image

I'm making a frogger type game, and i'm trying to make Mario jump on top of the log

Attachment:
File comment: The picture didn'w work, do this
screenshot105.png
screenshot105.png [ 6.37 KiB | Viewed 4800 times ]

_________________
"90 percent of everything is crap" - Some guy named Theodore
 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: Coding Help
PostPosted: Thu Jul 27, 2017 5:30 pm 
User avatar
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
@littlelum: Make sure Mario has a depth smaller than the Log's depth. So, Mario could have a depth=-1, while the Log could have the default depth=0.

 
Top
Offline 
 
 
 [us]
 Post subject: Re: Coding Help
PostPosted: Fri Jul 28, 2017 4:36 pm 
User avatar
¿
Good At French
[*]
[*]
[*]
[*]
Thanks. I thought it was in the sprite section, not objects :)

_________________
"90 percent of everything is crap" - Some guy named Theodore
 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: Coding Help
PostPosted: Tue Aug 08, 2017 10:07 am 
User avatar
12 years god help me
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
Wow is this all GML? I need to get back into Game Maker, I remember the code being challenging but it looks really easy now

 
Top
Offline 
 
 
 [us]
 Post subject: Re: Coding Help
PostPosted: Sun Aug 27, 2017 6:31 pm 
User avatar
This is official artwork
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
I know this sounds like a silly question, but does anybody know how to play as knuckles in the sonic game maker studio engine? I tried looking for a way to start testing the engine out as knuckles, but I could not find a way. Can someone please help me? Here is a link to it. https://forums.sonicretro.org/?showtopic=31723

_________________
Image      Image
 
Top
Offline 
 User page at mfgg.net
 
« Previous topic | Next topic »
Display posts from previous:  Sort by  
Go to page Previous  1 ... 37, 38, 39, 40, 41  [ 816 posts ]  Reply to topicPost new topic 


Who is online

Users browsing this topic: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group