2d skateboard game
-
How can I change the left and right on my controls to a thrust action velocity?
-
@waldron Hah, funny coincidence-- I've been working the past couple of weeks on a 2d, overhead rollerblading game! It'll be fun to compare what we come up with if you pursue the idea further :)
In my "engine", I have the player alternating "ZL" and "ZR" to do the thrusting forward. I can explain how I did it, is that what your question is?
-
@Spacemario yeah that's what I'm looking for,
Been working on this game for a while now and pretty much my main focus.
Thinking of keeping my current setup of controls but adding the zr for thrust il upload a vid soon -
@waldron Gotcha'! The kids are with grandma today, so I'm going to see how far I can get-- then I can just share my whole project, and you can copy out what you need! My "engine" is done, all I need to do is draw some more tiles, and put together a nice demo map.
But the gist of it is like this: I have a variable declared on the player sprite indicating which foot the player needs to use next, and which is initially set to "either". Then when I grab their input, I just toggle that variable from "left" to "right".
player.nextFoot = "either" ... if shouldReadInput and joy.zl and !joy.zr and (player.nextFoot == "left" or "player.nextFoot == "either") then player.speed += 1.5 player.nextFoot = "right" resetInput() // This is for my input filtering, as is "shouldReadInput" endif if shouldReadInput and joy.zr and !joy.zl and (player.nextFoot == "right" or "player.nextFoot == "either") then player.speed += 1.5 player.nextFoot = "left" resetInput() endif // If they are going slow, let them push with either foot if player.speed < .25 then player.nextFoot = "either" endif
You could also make "player.nextFoot" "strongly-typed" by making enum-style variables, instead of using a magic string like me.
Then I handle the player rotation in a speed-dependent way, like this:
if joy.lx != 0 then if player.speed == 0 then player.rotation += joy.lx * 2 else player.rotation += (joy.lx * player.speed) / 1.25 endf endif
The actual sprite drawing happens later on in the frame, like this:
setSpriteSpeed(player, {sin(player.rotation), -cos(player.rotation)} * player.speed * 100)
I also have lots of code to handle crashing, playing music/sfx, animation, moving the camera around to follow the player, and so forth. Once I share the whole thing, it'll make a lot more sense-- but hopefully this can at least get you going.
I don't know if you're going for a "Tony Hawk's Pro Skater"-style game, but it'd be awesome if you figured out a way to let the player "grind" on objects, like rails or steps!
-
@Spacemario thanks hopefully I can implement some of these controls, this one is in 2d as it's my very first project so I'm learning code as I go so dont want to deal with the complexity of a Tony hawk game (just yet) still in its early stages but getting there.!
-
Yeah grinding I'm wanting to just need to figure out how I can do it ! also being able the move up and down like a Simpsons game
-
@waldron Fixed the link for you. Looks great!
-
What! - i did not see that coming. This is awesome! Are you planning adding points for tricks while jumping and the like?
Great work on the graphics too! -
@Jonboy Thank you, yes and lots more tricks but its my first time coding so lots to figure out.
working on getting motion so the skater rolls with out stopping atm
then a point system. -
sorry dude but i have to call you out on that statement... There is no way, no chance whatsoever, that this is your first time coding. Come on be honest, you are not a total noob now are you?
If, and that's a slim chance indeed, it is your actual first time, then you are one to watch.
I for one will be watching very closely on how this develops.
Good luck sir.
-
@Jonboy Your making me go red, i think its down to the fuze 4 platform
with its tutorials and the fuze arena site with a brilliant!!! community.
Without this and you guys id be lost in a matrix of numbers and letters
Honestly thank you because believe me i could not do this on my own. -
really need to get this motion sorted feel like its gonna be the hook i need to make it a fun and challenging game
iv messed with the c.right and c.left adding allsorts to get my player to (roll) move and slowly slow down on its own
with no joy any help would be greatly appreciated. -
@waldron hey, happy to have a look and give some suggestions if you'd like to share your friend-code and game?
And just to confirm, you're looking to build in acceleration/deceleration and some Y axis movement?
Awesome progress btw!
-
@Tratax sweet iv shared it, my code is Waldron 6256-2637-1602
-
@waldron said in 2d skateboard game:
@Tratax sweet iv shared it, my code is Waldron 6256-2637-1602
cheers yeah, acceleration/deceleration and some Y axis movement would be perfect
-
@waldron You're cooking with gas, my friend. Skateboard game looks awesome!
-
@waldron Whoa, you really nailed that animation, it's fantastic! Stylistically, it reminds me of an even better "Skate or Die" on the NES.
-
@waldron hey - have updated the code and favourited the edits with some suggestions, re-shared this if you want to take a look.
The way i think of it is the skateboard always running in a state of movement, initiliasing the movement speed lower and utilising an "acceleration" variable as a multiplier in small increments that increases to a max or decreases to a negative max depending on how fast you want to go only when the buttons are held
The else condition highlighted then exists for the purpose if nothing is presssed to reduce that acceleration variable until it reaches 0 - may need to be split out as I didnt try this with left movement you could use your c. left and right to count up or down on that multiplier possibly
-
Also, it's got a great feeling, keen to see how this progresses!
-
@Tratax legend thank you il have a gander now cheers man