Mac OSX Game sometimes just doesn't recognize pickup

Hello everyone! Newbie here.

So let me try and explain this as best as I can. I'm making a single-screen 2D platformer where the basic goal is to collect a pickup in one spot and bring it to another. Collect them all and beat the level. Normally, this works just fine, but about 25% of the time I'll bring the pickup to the designated spot, and the game just won't take it / recognize it, thus I can't progress any further. When I restart the game, everything starts working correctly again, but this is still a big problem and I'm not sure how to fix it.

So any ideas? I can provide the code I've written so far if necessary.
 

Kyon

Member
without code there is exactly 0 ways to help you

haha, so yeah could you share some? Are you using drag/drop or writing scripts?
Also posts like this go better in "Programming" instead of "Community Tech Support"

MOD EDIT: Topic has been moved. :)
 
Last edited by a moderator:
Yeah sorry about that šŸ˜“ Next time I'll just include the code from the start

First here's the code for the Player:

CREATE
hsp = 0;
vsp = 0;
grv = 0.3;
walksp = 4;

pickup = -1;


STEP
//Get Player Input
key_left = keyboard_check(vk_left) || keyboard_check(ord("A"));
key_right = keyboard_check(vk_right) || keyboard_check(ord("D"));
key_jump = keyboard_check_pressed(vk_up) || keyboard_check_pressed(ord("W"));

//Calculate Movement
var move = key_right - key_left;

hsp = move * walksp;

vsp = vsp + grv;

if (key_jump)
{
vsp = -9;
audio_play_sound(snd_flap,5,false);
}


//Horizontal Collision
if (place_meeting(x+hsp,y,obj_wall))
{
while (!place_meeting(x+sign(hsp),y,obj_wall))
{
x = x + sign(hsp);
}
hsp = 0;
}
x = x + hsp;

//Vertical Collision
if (place_meeting(x,y+vsp,obj_wall))
{
while (!place_meeting(x,y+sign(vsp),obj_wall))
{
y = y + sign(vsp);
}
vsp = 0;
}
y = y + vsp;

///Room Wrap
move_wrap(true, false, sprite_width/2);

///Pickup
if (pickup!=-1)
{
pickup.x=x-0;
pickup.y=y-35;
}

if (pickup.x==256)
{
pickup.target_y = (256-32)-(global.Build*32);
pickup.dy=1;
pickup=-1;
}


COLLISION (with pickup)
if (pickup!=-1) exit;
if (other.build_id==(global.Build+1))
{
if (other.target_y<0)
{
pickup=other;
}
}



And here's the code for the Eggs (the pickup)

CREATE
global.Build=0;
build_id=0;

dy=0;
target_y=-1;


STEP
if (dy>0)
{
y+=dy;
if (y>=target_y)
{
y=target_y;
global.Build=build_id;
dy=0;
}
}
 
Top