Jump to content


Photo

Implementing Slopes


  • This topic is locked This topic is locked
10 replies to this topic

#1 iceflame1019

iceflame1019

    GMC Member

  • New Member
  • 846 posts

Posted 22 September 2007 - 06:44 PM

I had this topic in the Novice Q&A but so far only two problems have been addressed. What I really to know is how to implement slopes and get a good sprite rotation depending on the slope. IE I want the car to rotate up when going uphill and down when going downhill. Physics-wise this is a go-cart kind of game (or will be if I can get it to work).

My biggest issue right now is that I need to know how to implement slopes, and how to get the carts to roll on them instead of stopping. I've tried various "slope tutorials" yet I can't seem to alter them to make things fall downslope when they come to rest.

I currently have no slope things at all in the gm6 found in the Novice topic, since I can't get anything to work.

Summary of above: where do I find a good tutorial for my problem, or can anyone give me some pointers/codes/whatever? I learn best by tweaking examples but I can go with coding. I don't understand boolean yet so that's kind of a killer for me :blink: If you post a code, could you explain what the codes do?

EDIT here's the link to the gm6: http://upload2.net/p..._trial.gm6.html

If this shouldn't be here, please delete/close/whatever.

Edited by iceflame1019, 23 September 2007 - 11:25 PM.

  • 0

#2 Supertramp

Supertramp

    GMC Member

  • GMC Member
  • 353 posts

Posted 23 September 2007 - 05:14 PM

i'll try and help, but i need to know some things first:

1) is the sprite that you want to roll circular?
2) do you want it to rotate with image_angle, or is the sprite an animation?
3) do you want the object to accelerate down a hill and decelerate up a hill, or have a constant speed when it goes up or down?
4) will the slope have surves or just straight lines?
5) if the object hits a ramp, or a steep bit in the slope, will it keep spinning if it flies into the air or will it stop spinning?

if you answer these questions, i will do my best to help you

EDIT: i just realised what you mean. your sprite is a car or something like that, right?
well, that means that you need subimages for it, if you want the wheels to rotate, or you draw the car and the wheels separately.
just one more question - if your car flipps over onto its back, what do you want it to do?

Edited by Supertramp, 23 September 2007 - 05:19 PM.

  • 0
My examples:
Lightning Effect
Simple Minimap
Did I help you on something? PM me so i know
Click here to grow my city

#3 iceflame1019

iceflame1019

    GMC Member

  • New Member
  • 846 posts

Posted 23 September 2007 - 08:54 PM

1) no, your realization is correct. It's a parody of Mario's kart from, well, Mario Kart. It's in the gm6 accessible in the novice topic (I'm gonna put a link to that here)

2) I'm aiming for an animation--I thought image_angle rotated it even with animation?

3) preferably, but I can deal with same speed if acceleration is too difficult for either you to implement or for me to understand.

4) I don't know...would curves help them transition between flat and sloped surfaces, seeing how they're not circular objects?

5) (and answer to the edit) there will be no flipping onto the back, at least I hope. Just a lateral-spinnning animation like in cartoons or something after being hit or anything. I'd like them to fly off if they go fast enough up a slope but I can deal with the loss of that.

Thanks for offering to help!
  • 0

#4 Supertramp

Supertramp

    GMC Member

  • GMC Member
  • 353 posts

Posted 24 September 2007 - 07:38 AM

you would need to animate the wheels - how fast the car is going, and the car would haveto be rotated. dont worry about that yet.
but yes, image_angle rotates the whole image, even with animation. i'll see what i can do, but i can't do it at the moment. i'll be working on it!

EDIT: i have thought hard about it and i really can't think of a good way to do it. sorry
EDIT:i can't think of any way

don't worry, i'm sure that someone :ph34r: knows how to do it

Edited by Supertramp, 24 September 2007 - 06:09 PM.

  • 0
My examples:
Lightning Effect
Simple Minimap
Did I help you on something? PM me so i know
Click here to grow my city

#5 iceflame1019

iceflame1019

    GMC Member

  • New Member
  • 846 posts

Posted 26 September 2007 - 01:53 AM

-_-

Yeah, I know there's someone out there...trouble is finding that someone (or more than one).

Can anyone help me with this?
  • 0

#6 Supertramp

Supertramp

    GMC Member

  • GMC Member
  • 353 posts

Posted 27 September 2007 - 12:37 PM

a way you could do it is to step in the direction you are going and then move away from the ground untill you are not touching it. it would need a lot of work, but it's a start

Edited by Supertramp, 27 September 2007 - 12:37 PM.

  • 0
My examples:
Lightning Effect
Simple Minimap
Did I help you on something? PM me so i know
Click here to grow my city

#7 bahamut1993

bahamut1993

    GMC Member

  • New Member
  • 412 posts

Posted 27 September 2007 - 02:51 PM

Here's what I think:
Each ramp should have its own object.

On the collision event with any ramp:
direction=<Whatever angle the ramp is at>
image_angle=direction

Same with the ground:
direction=0
image_angle=direction

The reason the image_angle function isn't in the step event, is so you can make the car spin in the air.
  • 0
100% of all forum member-generated statistics are BULL. If you are part of the group of people that understand the hypocricy of this statement, do NOT copy it into your signature.

#8 Supertramp

Supertramp

    GMC Member

  • GMC Member
  • 353 posts

Posted 27 September 2007 - 08:33 PM

yes, i used something like that for a different game, but i couldn't get it to work properly.
to get the wheels to rotate, you could set the image_speed to the actual speed of the car divided or multiplied by something.
  • 0
My examples:
Lightning Effect
Simple Minimap
Did I help you on something? PM me so i know
Click here to grow my city

#9 dark_master4

dark_master4

    GMC Member

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

Posted 27 September 2007 - 09:38 PM

Use GMPhysics. The playground has a car (truck) example that can be tweaked easily. I myself modified it a bit to make it more car like than trucky, even added motion blur to the wheels so they look realistic. Of course I changed every sprites.

GMPhysics Topic
  • 0

My YoYoGames Marketplace (Has scripts, shaders and poker chips)


GM:Studio
Desktop Intel i5-4440 3.1ghz, 8gb RAM, NVIDIA GeForce GTX 770 2gb
Laptop AMD Athlon x64 2.1ghz, 4gb RAM, 256mb shared VRAM


#10 iceflame1019

iceflame1019

    GMC Member

  • New Member
  • 846 posts

Posted 28 September 2007 - 01:17 AM

looks awesome! I'll definitely look into this when I can dowload it without my wireless constantly dying!

BTW do I hafta do anything specific when dealing with dll's? (never had to before...)
  • 0

#11 dark_master4

dark_master4

    GMC Member

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

Posted 29 September 2007 - 09:17 PM

Everything should be explained by the author of the DLL, usually it's as simple as calling GM's built in functions. Some DLL aren't well commented though, in that case, try to ask the author for help.

[Edit]
Oh, and in the GMPhysics' playground, there is a car example already done, just press "E".

Edited by dark_master4, 29 September 2007 - 09:18 PM.

  • 0

My YoYoGames Marketplace (Has scripts, shaders and poker chips)


GM:Studio
Desktop Intel i5-4440 3.1ghz, 8gb RAM, NVIDIA GeForce GTX 770 2gb
Laptop AMD Athlon x64 2.1ghz, 4gb RAM, 256mb shared VRAM