I'm making my own collision script, but I can't make the object I touched as an argument. I even tried to do it with one object but it won't work. Mario just falls through the ground.
Here's the code I used:
Script:
Code:
bleft = obj_solidground.bbox_left
btop = obj_solidground.bbox_top
bright = obj_solidground.bbox_right
bbottom = obj_solidground.bbox_bottom
if argument0 > bright
or argument3 < bleft
or argument1 > bbottom
or argument4 < btop
return true;
else
return false;
Mario step event
Code:
if col_rect(bbox_left,bbox_bottom,bbox_right,bbox_bottom+2)
and yspeed = 0
if xspeed = 0
state = 0
else
state = 1
else
state = 2
y += yspeed
yspeed = min(yspeed+grav,4)
if col_rect(bbox_left,bbox_bottom,bbox_right,bbox_bottom+2)
{
topblock = collision_rectangle(bbox_left,bbox_bottom,bbox_right,bbox_bottom+2,obj_solidground,1,1)
if not yspeed < 0
{
y = topblock.bbox_top-31
yspeed = 0
grav = 0
jumpnow = 0
}
}
else
{
if yspeed < -1
grav = 0.1
else
grav = 0.3
}
Help would greatly release my fangame early
.
EDIT: Anyone help me?
I'm making my own collision script, but I can't make the object I touched as an argument. I even tried to do it with one object but it won't work. Mario just falls through the ground.
Here's the code I used:
Script:
[code]
bleft = obj_solidground.bbox_left
btop = obj_solidground.bbox_top
bright = obj_solidground.bbox_right
bbottom = obj_solidground.bbox_bottom
if argument0 > bright
or argument3 < bleft
or argument1 > bbottom
or argument4 < btop
return true;
else
return false;
[/code]
Mario step event
[code]
if col_rect(bbox_left,bbox_bottom,bbox_right,bbox_bottom+2)
and yspeed = 0
if xspeed = 0
state = 0
else
state = 1
else
state = 2
y += yspeed
yspeed = min(yspeed+grav,4)
if col_rect(bbox_left,bbox_bottom,bbox_right,bbox_bottom+2)
{
topblock = collision_rectangle(bbox_left,bbox_bottom,bbox_right,bbox_bottom+2,obj_solidground,1,1)
if not yspeed < 0
{
y = topblock.bbox_top-31
yspeed = 0
grav = 0
jumpnow = 0
}
}
else
{
if yspeed < -1
grav = 0.1
else
grav = 0.3
}
[/code]
Help would greatly release my fangame early :D .
EDIT: Anyone help me?