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: Zelda slope sliding with this code?  (Read 2479 times)

0 Members and 1 Guest are viewing this topic.
Zelda slope sliding with this code?
« on: January 22, 2012, 02:21:41 am »
  • *
  • Reputation: +2/-0
  • Offline Offline
  • Gender: Male
  • Posts: 269
Hello, i have been trying to get a slope collision(top down, just regular 45 degree slopes) for a while but as i am not very good at collisions it is hard without rewriting alot of whats written. as of now i have
Code: [Select]
x += (place_empty(x+4,y)*keyboard_check( vk_right) - place_empty(x-4,y)*keyboard_check(vk_left) )*4;

y += (place_empty(x,y+4)*keyboard_check( vk_down) - place_empty(x,y-4)*keyboard_check(vk_up) )*4;
as my collision code, and i was wondering how to have this as the zelda style slope code also. what i mean by that is if im hitting a slope going up and to the left, and im just holding up, i will kind of slide against the slope at a diagonal way. does anyone know how to insert this in with the code above? also i have 4 different objects with the 4 directions of slopes. so yes. if anyone knows how to solve this please help or if anyone needs more information i will be happy to give some.
Logged
Re: Zelda slope sliding with this code?
« Reply #1 on: January 22, 2012, 07:17:54 am »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3725
First: I would suggest you look through this http://zfgc.com/forum/index.php?topic=38347.0 for a bit. You will learn a lot about how to do movement.

Second: Describe in simple words the complete effect of going up and down a slope.
Logged
Re: Zelda slope sliding with this code?
« Reply #2 on: January 22, 2012, 05:06:55 pm »
  • *
  • Reputation: +2/-0
  • Offline Offline
  • Gender: Male
  • Posts: 269
First: i have looked through that, and as far as i remember its a very complicated thing to learn from, expesially because i cant find anything on collisions that i even understand, and its hard to just copy peices of code or learn from it because of it. so i have disregarded the minish engine, and ill try again, but i doubt ill find anything to work with.
Second: im not sure what you mean by this.. but
if you are holding up and you collide with the slope, the slope does not just stop you there, itmakes you sort of ride against the slope going up and left. the same for other directions, sort of shimmying up the slope instead of a dead on collision.
Logged
Re: Zelda slope sliding with this code?
« Reply #3 on: January 22, 2012, 06:35:10 pm »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3725
Second: im not sure what you mean by this.. but
if you are holding up and you collide with the slope, the slope does not just stop you there, itmakes you sort of ride against the slope going up and left. the same for other directions, sort of shimmying up the slope instead of a dead on collision.
What I mean is that if you explain it in simple words how you would go through the entire movement calculation you can make for your self a flow chart of what needs to be done. This is the design phase of your project. In the MCS engine a general flowchart for player movement is in the attachment.

But if I understand it correct then a slope has a direction of travel. And when the player moves in the direction of the slope, he will go faster on a fixed course until he is of the slope again. If the player moves in the opposite direction of the slope than the player is pushed back until he is of the slope again. However the speed change is not instant, but goes gradually towards the direction of the slope.

This seems to me not a problem with collision checking, but with checking for surface effects that are used in the calculation of the x and y translations, before the collision checking.
Logged
Re: Zelda slope sliding with this code?
« Reply #4 on: January 23, 2012, 08:43:11 pm »
  • *
  • Reputation: +2/-0
  • Offline Offline
  • Gender: Male
  • Posts: 269
Thank you, but im not sure how to execute that in a clean collision code.. because whenever i try Link would move very choppy and stuff and its just hard to figure out why, since i never took great time to learn collisions, and now thats coming back to screw me over. i cant figure out what to do even with the skill tree.. i cant find the right codes to execute.
Logged
Re: Zelda slope sliding with this code?
« Reply #5 on: January 24, 2012, 10:40:09 am »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3725
If you really need to learn some more and don't have the confidence, then I would suggest that you make your source code available. We can't help you much from the lines you have provided. Besides we might be able to offer advice on other areas as well.

Code: [Select]
x += (place_empty(x+4,y)*keyboard_check( vk_right) - place_empty(x-4,y)*keyboard_check(vk_left) )*4;
Advice 1: From this line of code I can see that you are trying to do 3 different processes at once: 1) Checking for player input, 2) Calculating x axis translation, and 3) Resolve x axis movement (collision detection). This isn't wrong for very simple games, but the more complex your game becomes the more trouble you get with this line. Try to do the processes in separate statements.

Advice 2: Use position_meeting or place_meeting instead of place_empty. And define objects named parObstacle and parSurface. Those objects that inherit from parObstacle will impede the player's movement. Those that inherit from parSurface will only affect the player's movement, but not impede it.
Logged
Re: Zelda slope sliding with this code?
« Reply #6 on: January 24, 2012, 01:06:59 pm »
  • *
  • Reputation: +2/-0
  • Offline Offline
  • Gender: Male
  • Posts: 269
Thank you for al the advice, i greatly appreciate it. And well what i was going to do was once i finish all my basic actions, for once im sticking to just an engine and grinding out source code until i get every movement i want, and the last one i have right now is collisions. I really wAnt to keep the source univalable for a little bit longer until i finish up some more stuff. As for number two, thanks! That actually givese mE an idea on how to go at this again. Parobstacle is the same as just "Wall" in my game. And all the slopes had "Wall" as parent. So yours kindof explains in detail what i need to dothat differs the slopes and such. Thanks for all the input, i love forums that are active and everyone on it can give help like this!
Logged
Pages: [1]   Go Up

 


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



Page created in 0.042 seconds with 51 queries.