C
CongoBongo
Guest
Hi, so i'm fairly new with programming with physics in Game Maker, I used to do simple games with the implemented features and buttons (like 8 years ago) and decided to re-download Game Maker after I got an idea for a game this morning, I didn't check tutorials or anything just used the Game Maker Manual which had all the variable names and stuff I'd use and just put my noob-ish Python knowledge in action to see if I could make a simple side-scrolling physics game.
Basically, you're a submarine underwater in the form of an endless side-scroller with 'gravity', if you go into the depths you lose or if you run into enemies too much (haven't even gone past the players physics), you have a limited amount of boost which you use with Spacebar and slowly replenishes over time, you'd use the Up-Down keys to tilt the sub and then boost to go in that direction, ideally you're like cruising so you have to be fluent and not use up all boost. You can recharge fuel from 'fuel-trails' from other ships or grab fuel bars and avoid mines, etc... with a score timer and a boost 'bar', in theory I know how to code this in terms of logical sense but in terms of semantics and how GM interprets the code I'm lost...
Under the Create Event I put two different 'Execute code' buttons, the first one would define some variables and the second one would apply these whenever you press space to boost.
1st code:
boost = 0;
press_space = keyboard_check_pressed(vk_space);
2nd code:
if press_space == 1
{
boost ++;
}
while boost < 100
{
physics_apply_force(ship.x,ship.y,10,0);
}
I tried to put the While inside the If, changed indentations, fooled around with operators, changed the 1's to trues' and trues' to 1's. I also swapped their Events around, using Step or Spacebar (which just crashed it), and also changed the ship.x and ship.y to numerical values or 'ship' alone /// ship is the player name
After this I tried simplifying my code into:
if keyboard_press_check(vk_space)
{
physics_apply_force(x,y,10,0)
}
Still, even without the whole boost thing it didn't work :L I incremented the boost to a much higher value and nothing happened.
The results were either that the game crashed and couldn't even start-up, forcing me to shut it down or it crashed when I pressed Space or just didn't work at all. I tried running it in de-bug mode but didn't retrieve any good info, to be honest I could troubleshoot after changing single variables which I mentioned above but it would take too much time and I'd rather get an insightful answer from the community
Here are some screenshots of the player phys properties and world phys. if you need 'em:
Sorry for the long thread, I don't post much on forums but I'd really appreciate a hand or at least an explanation of why it doesn't work Thanks.
EDIT:
Before using the above mentioned physics_apply_force I was using physics_apply_impulse. However, the results didn't differ.
Basically, you're a submarine underwater in the form of an endless side-scroller with 'gravity', if you go into the depths you lose or if you run into enemies too much (haven't even gone past the players physics), you have a limited amount of boost which you use with Spacebar and slowly replenishes over time, you'd use the Up-Down keys to tilt the sub and then boost to go in that direction, ideally you're like cruising so you have to be fluent and not use up all boost. You can recharge fuel from 'fuel-trails' from other ships or grab fuel bars and avoid mines, etc... with a score timer and a boost 'bar', in theory I know how to code this in terms of logical sense but in terms of semantics and how GM interprets the code I'm lost...
Under the Create Event I put two different 'Execute code' buttons, the first one would define some variables and the second one would apply these whenever you press space to boost.
1st code:
boost = 0;
press_space = keyboard_check_pressed(vk_space);
2nd code:
if press_space == 1
{
boost ++;
}
while boost < 100
{
physics_apply_force(ship.x,ship.y,10,0);
}
I tried to put the While inside the If, changed indentations, fooled around with operators, changed the 1's to trues' and trues' to 1's. I also swapped their Events around, using Step or Spacebar (which just crashed it), and also changed the ship.x and ship.y to numerical values or 'ship' alone /// ship is the player name
After this I tried simplifying my code into:
if keyboard_press_check(vk_space)
{
physics_apply_force(x,y,10,0)
}
Still, even without the whole boost thing it didn't work :L I incremented the boost to a much higher value and nothing happened.
The results were either that the game crashed and couldn't even start-up, forcing me to shut it down or it crashed when I pressed Space or just didn't work at all. I tried running it in de-bug mode but didn't retrieve any good info, to be honest I could troubleshoot after changing single variables which I mentioned above but it would take too much time and I'd rather get an insightful answer from the community
Here are some screenshots of the player phys properties and world phys. if you need 'em:
Sorry for the long thread, I don't post much on forums but I'd really appreciate a hand or at least an explanation of why it doesn't work Thanks.
EDIT:
Before using the above mentioned physics_apply_force I was using physics_apply_impulse. However, the results didn't differ.
Last edited by a moderator: