![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Feb 2005
Posts: 24
Rep Power: 0
![]() |
pygame half-pipe game
hey,
i'd like to make a simple 2D half-pipe game using pygame. this is what inspired me: http://www.gmaxskateboarding.com/game.asp however, i'm not sure about the maths involved in coding this kind of game. i'll need to make the skater move along the half-pipe, rotating him accordingly so he appears to stay in an upright position. i'd appreciate it if anyone could point me in the right direction. i'm aware of the pygame.transform.rotate method, as well as pygame.draw.arc (could maybe use to draw the half-pipe?) oh, and i tried to read up on bezier curves but it just went over my head! |
|
|
|
|
|
#2 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,799
Rep Power: 5
![]() |
Start by making a function that will convert a given x position (1 dimension), in to a x, y tuple (2 dimensions) by placing it on a parabolic curve.
The pipe will have the same equation as the parabolic curve, and it will be represented by an image (you're limiting yourself by using functions like pygame.draw.arc). Then try displaying the skater on the pipe in various locations by using your 1-2 dimension converting function. Then manipulate the x position in a periodic function after reading up on some physics. Add user input which will vary the dependants that the physics calculations use. That would probably be the order in which I would do this. Although other people would do it differently. Everyone has their own way which works for them. Good luck. |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Feb 2005
Posts: 24
Rep Power: 0
![]() |
thanks for the help, i'll give what you suggested a try
![]() |
|
|
|
|
|
#4 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,799
Rep Power: 5
![]() |
I apolagize, I forgot about one of the most important parts. The rotation.
![]() The red circle is the skater. The blue lines are the tangents/x axis. The green is the determined angle of rotation. The tangent is calculated by solving for the immediate slope. I won't bother going over this, because noting your age, you would have already. Then the angle of rotation is solved with trigonometry, by drawing a triangle with the x axis as shown in the picture (I left out the opposite side to avoid messiness, plus it is not needed). This may not be the fastest way to calculate it, mind you. Also, it may be a good idea to pre-determine all the values that this function can output, by a set integer interval. That will reduce the redundancy of calculating the angle every time the skater passes each similar point. |
|
|
|
|
|
#5 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4
![]() |
You could also treat the half-pipe as a mathematical curve. Differentiate the curve to find the tangent, find the perpendicular, and use trigonometry to find the corresponding angle to rotate it by.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Trying to setup an anti-cheat system for a game friend and I are creating | Dr.Backtick` | C++ | 14 | Feb 15th, 2006 11:12 PM |
| Java programmers, game developers, artists, be ware! RPG game team is recruiting! | atcomputers.us | Paid Job Offers | 7 | Sep 25th, 2005 7:25 PM |
| a simple 2d game, faster in pygame or pyopengl? | cypherkronis | Python | 1 | Jun 30th, 2005 7:57 PM |
| Programmers Needed! Online Game | troy_eisert | C++ | 2 | Jan 29th, 2005 12:51 PM |