Jump to content


Photo
* * * * * 1 votes

Simple Platformer Movement


  • Please log in to reply
21 replies to this topic

#1 Swifty

Swifty

    Shadow

  • GMC Member
  • 370 posts
  • Version:GM:Studio

Posted 03 April 2012 - 06:02 PM

  • Title: Simple, Smooth Platformer Movement
  • Description: Movement on slopes
  • GM Version: :GM8_new:/>
  • Registered: No (Delete draw code in player and it should work fine)
  • File Type: .gm81
  • File Size: 35 KB
  • File Link: Smooth Platformer Movement.gm81
  • Required Extensions: None
  • Required DLLs: None
Try before you download: Try out the HTML5 example version Right Here!

Summary

One simple script for smooth, flawless platformer movement, up and down sloped surfaces.
The player will stay to the ground and move up and down any type of custom drawn surface(see screenshot)!
All you have to do is copy the players creation variables, the movement script (which runs in the step event)
and the collision code with the ground - and you can easily integrate this into your own game in minutes.

-

What others think:
Spoiler


Screenshot:
Posted Image

Tags: GMCTUTORIAL, GMCPLATFORM, GMCMOVEMENT

Swifty

Edited by Swifty, 11 January 2013 - 01:43 AM.

  • 0

#2 ggaamm

ggaamm

    GMC Member

  • New Member
  • 6 posts
  • Version:GM8

Posted 06 April 2012 - 08:29 AM

Hey, this looks like it'd be great, buuuuuuutttttttttttttttt, the download link brought me to a page of gibberish.
  • 0

#3 Swifty

Swifty

    Shadow

  • GMC Member
  • 370 posts
  • Version:GM:Studio

Posted 06 April 2012 - 12:10 PM

@ggaamm - Sorry about that, the link downloaded fine on my end but I've thrown it up on dropbox for you and pasted the direct link. Try again and let me know how it turns out.

Swifty

Edited by Swifty, 06 April 2012 - 12:10 PM.

  • 0

#4 ggaamm

ggaamm

    GMC Member

  • New Member
  • 6 posts
  • Version:GM8

Posted 08 April 2012 - 01:24 AM

This is great! Probably the smoothest slope example i have seen on here. And it is visually extremely nice to look at.
  • 0

#5 Swifty

Swifty

    Shadow

  • GMC Member
  • 370 posts
  • Version:GM:Studio

Posted 18 June 2012 - 09:58 AM

I've edited this example, fixed a small bug, and made it so when you jump and hit something above you, you fall down instead of getting stuck.

Swifty
  • 0

#6 Mr_H4mm3r

Mr_H4mm3r

    GMC Member

  • New Member
  • 1 posts
  • Version:GM8

Posted 24 June 2012 - 06:50 PM

Can you add possible for jumping when you're running / walking?

*Edit*
I changed my jump height in the ScrMovement script

//JUMPING - simple code, limits our jump to one
if keyboard_check_pressed(ord("W")) && jump = true{
    vspeed -= 5
    jump = false
}

But when I jump and then walks when I'm in the air it teleports down to the ground..?

Edited by Mr_H4mm3r, 24 June 2012 - 06:54 PM.

  • 0

#7 Swifty

Swifty

    Shadow

  • GMC Member
  • 370 posts
  • Version:GM:Studio

Posted 25 June 2012 - 03:21 AM

Can you add possible for jumping when you're running / walking?

*Edit*
I changed my jump height in the ScrMovement script

//JUMPING - simple code, limits our jump to one
if keyboard_check_pressed(ord("W")) && jump = true{
    vspeed -= 5
    jump = false
}

But when I jump and then walks when I'm in the air it teleports down to the ground..?

Hey Mr_H4mm3r, you can jump while you're running/walking, if you hold down A/D and press W it will make the player jump. By changing the:
if keyboard_check_pressed(ord("W")) && jump = true{
to
if keyboard_check_pressed(vk_space) && jump = true{
it might make it easier for you to press space bar rather than W.

Okay now as for the issue you're having; if you look at the objPlayers Create Event - you'll see a variable called height and it should be set to 6. What this does is when you love left or right and there's a block in the way, it will check up to 6 pixels in height and move your up if there's a free spot.
So if your vspeed is less than the height variable you will always get pulled back to the ground! So make sure vspeed is at least 1 higher than the height.
For Example if your vspeed is set to:
vspeed -= 5
than change the objPlayers height variable to:
height = 4
Swifty

Edited by Swifty, 25 June 2012 - 03:29 AM.

  • 0

#8 talonstart

talonstart

    Artist

  • GMC Member
  • 442 posts
  • Version:GM:Studio

Posted 25 June 2012 - 01:06 PM

wish i could download this.. interested in the coding.
  • 0

#9 Swifty

Swifty

    Shadow

  • GMC Member
  • 370 posts
  • Version:GM:Studio

Posted 25 June 2012 - 01:14 PM

wish i could download this.. interested in the coding.

Why are you unable to download? I could probably throw up the main Movement script here if you liked?

Swifty
  • 0

#10 talonstart

talonstart

    Artist

  • GMC Member
  • 442 posts
  • Version:GM:Studio

Posted 26 June 2012 - 01:56 PM

Worked now bud , Thanks alot.. :)

EDIT:
reading this, this is flawless, and exactly what i was trying to figure out. lovely job.
Also just wanted to comment. (i like your sprites!).. very cool. did you make them?

Edited by talonstart, 26 June 2012 - 02:01 PM.

  • 0

#11 Swifty

Swifty

    Shadow

  • GMC Member
  • 370 posts
  • Version:GM:Studio

Posted 26 June 2012 - 02:33 PM

Worked now bud , Thanks alot.. :)

EDIT:
reading this, this is flawless, and exactly what i was trying to figure out. lovely job.
Also just wanted to comment. (i like your sprites!).. very cool. did you make them?

Cheers, thanks for the compliment! Yep I did all the sprite work and animations :) so thanks again, haha the rock at the start is really dodgy but I just threw that in to make sure jumping and hitting something above you was working.

Well I'm glad you like it, and I hope you can put it to good use!

Edit: So the coding/commenting in the example was all easy enough to understand? I'll probably do up a small guide on how exactly it works etc for people who might want to try and understand It better and can't quite wrap their head around the code or whatever.

Swifty

Edited by Swifty, 26 June 2012 - 03:46 PM.

  • 0

#12 HatchetHarriette

HatchetHarriette

    GMC Member

  • New Member
  • 16 posts
  • Version:GM8

Posted 26 June 2012 - 11:25 PM

This works really well, I see the first lines there where you check if the place is free at (x, y+1)*0.55

I'd really like to know how multiplying the place check co-ords by 0.55 benefits the movement and if that is what makes the movement work so well. Any reply and explanation would be great.

Thanks!
  • 0

#13 Swifty

Swifty

    Shadow

  • GMC Member
  • 370 posts
  • Version:GM:Studio

Posted 27 June 2012 - 03:28 AM

This works really well, I see the first lines there where you check if the place is free at (x, y+1)*0.55

I'd really like to know how multiplying the place check co-ords by 0.55 benefits the movement and if that is what makes the movement work so well. Any reply and explanation would be great.

Thanks!

Hey the piece of code you're looking at is for the players gravity. It just slows the pull of the play down a bit - it's more so personal preference.
I'll do up a short tutorial/document soon, as to how the code is working and why it's so smooth.

Glad you liked it though! If you have any more questions/comments let me know.

Swifty
  • 0

#14 talonstart

talonstart

    Artist

  • GMC Member
  • 442 posts
  • Version:GM:Studio

Posted 27 June 2012 - 01:45 PM

Im in love with this, It's exactly what i was looking for my platforming games. (of course i might ask you some questions down the road)..
I'm planing a side scrolling rpg.. (but i need high detailing spriters other then myself, and coders). I dont wanna start the project unless i know for sure
its worth my time..

But ima set up levels, and figure out some things..

i need arrow keys (<,>,^,v) (space to jump) , and a hotbar that works.a,s,d,f and z,x for low attack/heavy attack. , q and w for health and mana...
but i think i can handle that stuff..

Just no idea how to make a hotbar / inventory system / char select. . . :(

Edited by talonstart, 27 June 2012 - 01:47 PM.

  • 0

#15 HatchetHarriette

HatchetHarriette

    GMC Member

  • New Member
  • 16 posts
  • Version:GM8

Posted 29 June 2012 - 01:55 PM


This works really well, I see the first lines there where you check if the place is free at (x, y+1)*0.55

I'd really like to know how multiplying the place check co-ords by 0.55 benefits the movement and if that is what makes the movement work so well. Any reply and explanation would be great.

Thanks!

Hey the piece of code you're looking at is for the players gravity. It just slows the pull of the play down a bit - it's more so personal preference.
I'll do up a short tutorial/document soon, as to how the code is working and why it's so smooth.

Glad you liked it though! If you have any more questions/comments let me know.

Swifty



Sounds good, I'll look forward to your tutorial.

~HH
  • 0

#16 ELECTRONICUS

ELECTRONICUS

    GMC Member

  • New Member
  • 12 posts
  • Version:Unknown

Posted 12 July 2012 - 05:11 PM

Wow, this is amazing! :) Too bad I can't open it since I'm making my game in GM8. :'(
Can somebody please just copy paste the script and send it to me? I would be thankful.

Edited by ELECTRONICUS, 12 July 2012 - 07:46 PM.

  • 0

#17 ELECTRONICUS

ELECTRONICUS

    GMC Member

  • New Member
  • 12 posts
  • Version:Unknown

Posted 14 July 2012 - 02:06 PM

When in mid-air, how can I continue to go in one direction when I release left/right button? It is not looking realistic if the player just stops when I release the button. :/
  • 0

#18 harry_howarth

harry_howarth

    GMC Member

  • New Member
  • 2 posts
  • Version:Unknown

Posted 15 July 2012 - 11:03 AM

Just dropping a comment to say that the code is very elegant and I'm currently looking at including it in two of our projects.

A couple of questions however:

How would you go about adding a 'skid to a stop' when moving left or right?

Would it be possible to adapt this code for use within an enemy AI script, with keypress checks swapped out for other triggers?

Look forward to reading the written tutorial on this so I can better explain it to my collegue.
  • 0

#19 Swifty

Swifty

    Shadow

  • GMC Member
  • 370 posts
  • Version:GM:Studio

Posted 15 July 2012 - 01:55 PM

Thanks so much for the kind comments guys, glad to know you like the tutorial. I'll try to get an example for you ELECTRONICUS and also you harry_howarth as you seem to both want a similar feature. I've been pretty busy but I'll try and get something for you guys asap!

Swifty
  • 0

#20 ELECTRONICUS

ELECTRONICUS

    GMC Member

  • New Member
  • 12 posts
  • Version:Unknown

Posted 15 July 2012 - 08:21 PM

Unfortunately, I have returned to Martin Piecyk's engine because I wanted to implement this in that engine but when it didn't work I just gave up... I love that engine because it has everything programmed so it would be just perfect if someone help me to implement these few lines of code in that, because the problem with that engine is when I run up the slopes my character slows his movement and I want him to run up and down the slopes in the same speed. :(
I opened a few topics but nobody helped me. I can't start working on my project till I fix that. :/

Here is the engine and if someone help me I will put them in credits for sure because that thing is really really important to me.

http://martinpiecyk....gine/index.html

The other way is to change the code in script in Character Step Event but I don't know how because it is very complicated.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users