Jump to content


MrEvil178

Member Since 05 Feb 2006
Offline Last Active Jun 06 2010 06:46 PM

Topics I've Started

Questions About Some Code

30 May 2010 - 05:51 PM

I was taking apart the collision code from here and I was confused by some of it. I was wondering if I could have some help.

if (block_below >= 0) && !place_meeting(x,y,block_below)

I am uncertain what this means. I know that the "!place_meeting" function is checking that an object isn't there but what does using an variable instead of an object do?

I was also wondering what value:

abs(xmove)

would return in the context of this code. Reading the manual, it says that this would retrieve the absoloute x value. Does that mean this adds "xmove" to the x co-ordinant relative to the object?

Thanks.

Am I Doing This Right?

26 May 2010 - 09:14 PM

Hey I've been trying to learn GML recently and have come across a little problem.

right = vk_right
left = vk_left
jump = vk_up


if !keyboard_check(left) && keyboard_check(right)
{
	if place_free(x+hspeed,y) then hspeed = 12 else hspeed = 0
}
			
if !keyboard_check(right) && keyboard_check(left)
{
	if place_free(x-hspeed,y) then hspeed = -12 else hspeed = 0
}

Now here I want it to stop moving when nobody is pressing the keys. However instead the object keeps moving the direction you last pressed it. It seems to ignore the second part of the if statment. If anyone is wondering, yes this is from the SparkEngine I was seeing how I could use it to learn GML.

if !instance_place(x,y+1,WALL)
gravity=0.5
if instance_place(x,y+1,WALL)
gravity=0
if vspeed>10
vspeed=10

(the object WALL is not solid by the way)

The player should not fall through the wall as gravity is turned off when they are near it. Also here, the player falls through the walls as if it ignores the second if statement again. I'm really uncertain what I am doing wrong in both of these instances.