• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

New, new help with top down jumping game

B

BlazeDragon

Guest
I'm not sure where to post this, this is my first post. I've made top scrolling shooters before and get the idea behind it. I can also do basic pacman like games. I'm trying to build a jumping game as a top down. closest thing would be frogger with the logs.

The idea is that you would have a character starting on a truck on the highway. When you start the truck is driving, I need the character to stay with the truck...no idea how....

Trucks will randomly appear and the player would have to jump from truck to truck. By doing so you would then follow that truck like the logs in frogger. If you go off screen it would push you off the truck and you would die. If you miss jumping on a truck, you would die. the game would score you per second on how long your alive.

I have no idea how to make the player stick with the truck or how to register that if they are not in a truck they die...

can anyone help? or direct me to the proper place in the forums please?

thank you for your time
 
C

chico_haze

Guest
In the player object, have a variable called "truck" and assign it to the instance of truck the player is currently riding. Then, in the Step event for the player object, you would have a couple lines like this:
x = truck.x;
y = truck.y;

When the player jumps to a new truck, you just reassign your truck variable to the new instance and the player will move along with that truck.
 

TheouAegis

Member
I could make a Frogger clone using just bit translations... Challenge accepted! That will keep my ADD happy this week.

BTW, you want it to be in the END step event so the player stays with the truck after it moves.
 
B

BlazeDragon

Guest
I'm sorry what do you mean the instance of the truck the player is currently riding?
upload_2017-1-22_7-5-58.png

Do you mean this?

I feel like your referring to something else...

Essentially what I am trying to do is:
if player moves
test position
if position = no object
end game show high score
if position = object
player position = position relative to object
end if
 
B

BlazeDragon

Guest
I've been playing around with this...but still no good :(

upload_2017-1-22_8-53-41.png
 

TheouAegis

Member
y = y-(y mod 64)...

So y = y & ~63...

... + (obj_truck.x mod 64)

Um... Why are you adding the truck's x coordinate to the player's y coordinate? And why are you even using mod 64 there?


truck = collision_rectangle(blahblahblah)

That gives you the ID of the truck the player collides with. That is what you need to use from here on out. However, in your code you insist on using obj_truck. That could be any truck object in the room anywhere, not the one you're riding. The one you're riding is inside the variable truck, so use that variable if it's set.

truck = collision_rectangle(blahblahblah, obj_truck);
if !truck truck = collision_rectangle(blahblahblah, obj_greyvan);
if truck {
if x < 1080 {
y = truck.y;
vspeed = truck.vspeed;
}}
 
B

BlazeDragon

Guest
y = y-(y mod 64)...

So y = y & ~63...

... + (obj_truck.x mod 64)

Um... Why are you adding the truck's x coordinate to the player's y coordinate? And why are you even using mod 64 there?


truck = collision_rectangle(blahblahblah)

That gives you the ID of the truck the player collides with. That is what you need to use from here on out. However, in your code you insist on using obj_truck. That could be any truck object in the room anywhere, not the one you're riding. The one you're riding is inside the variable truck, so use that variable if it's set.

truck = collision_rectangle(blahblahblah, obj_truck);
if !truck truck = collision_rectangle(blahblahblah, obj_greyvan);
if truck {
if x < 1080 {
y = truck.y;
vspeed = truck.vspeed;
}}

I only used that based upon a video I ran across. Was not sure if mod 64 was the best path and i couldn't get it to work. originally it would only push the player character. I found this in a youtube video that gave a tutorial on making frogger clone. Trying to simulate jumping on the logs but they be trucks and if you miss and hit the highway you die. now it doesn't run at all :S

I thought this would work because I figured I would be setting the player cordinates x and y to match the object it collides with. If there is a better method by all means let me know, because right now I am just going off research.

The obj_truck, in the video at least was a universal obj that would act with directs etc but draw different sprites based upon code entered at the room level. In the video it suggested doing this so as not to have to redo the code over and over.

As you can see I took out that code cause none of it was working.... I'll gives yours a try and respond. Thank you :)

upload_2017-1-22_16-49-2.png
 
B

BlazeDragon

Guest
I get an error on line 13...

upload_2017-1-22_16-52-58.png


//movement
if keyboard_check_pressed(vk_right){x+=118}
if keyboard_check_pressed(vk_left){x-=118}
if keyboard_check_pressed(vk_up){y-=118}
if keyboard_check_pressed(vk_down){y+=118}


//death
//if y<view_yview || y>view_yview+view_wview{scr_die()}
//if x<1080 && !place_meeting(x,y,obj_truck){scr_die()}


truck = collision_rectangle(x+1,y+1,x+62,y+62, obj_truck);
if !truck truck = collision_rectangle(x+1,Y+1,x+62,y+62, obj_greyvan);
if truck {
if x < 1080 {
y = truck.y;
vspeed = truck.vspeed;
}}
 
Top