Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: HELP: Slopes  (Read 952 times)

0 Members and 1 Guest are viewing this topic.
HELP: Slopes
« on: December 10, 2006, 09:22:58 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 413
Slopes. I can never figure them out.
I have a fairly standard platform engine and I have a slope of 45??. How do I make my character go up the slope?
I've tried various methods, ranging from simply making the character's y value decrease by one whenever it touches the slope, to individually checking each pixel to determine whether the character should move up or not. These tend to be messy and work badly. What would be the easiest way to create a working slope?
Logged
Re: HELP: Slopes
« Reply #1 on: December 10, 2006, 09:29:49 pm »
  • =/
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 2284
 I'm not sure what program your using so I'll assume GM from what you have said. What I would do is manually move the character in that direction, instead of trying to make the dude automaticly check for slopes.
As in:
Code: [Select]
//Go up the slope to the right
if dudeistouchingtheotherdude and keyboard_check(vk_right){
 y += 1
 x += 1
}

(Sorry for the pretty shitty example, I'm not really in a coding mood right now.)
Logged

mit

Re: HELP: Slopes
« Reply #2 on: December 12, 2006, 07:41:10 pm »
  • QBASIC programmer since age 4. Take that, world.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 1079
If you look at the gamemaker official tutorial for platformers, you'll see he has a basic staircase. This does similar to:

if place_free( to the left ) then move left
else if place_free ( to the left and up ) then move left and up

Using that sort of idea, it'd be fairly simple to make a loop of how much up you're checking, and move to there (you'd probably want to make him move less if the slope is steeper).

For going down slopes, do the same thing. Just move it down instead. The character will cling to the slope, but it's better than moving to the side and then falling again and again.

EDIT: For obvious reasons, check for going down before checking for going up. Only move up if you can't go down... ;)
« Last Edit: December 12, 2006, 07:42:57 pm by mit »
Logged
Programmer / Spriter / Level designer / Game Director / Web Designer / Music Sequencer for
Random Highscore table:

Play the Kousou Arcade today!
  • Kousou Games
Re: HELP: Slopes
« Reply #3 on: December 14, 2006, 04:53:16 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 413
That's a damn good idea, I'll try it now.
And yes, I'm using Game Maker.
Logged
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.398 seconds with 45 queries.