Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / need some mathematical help

Author
Message
haliop
User Banned
Posted: 5th Apr 2010 20:17
hi , if you guys saw the DarkGDK competition
for April
you know we are building a SideScroller

my enemies have some abilites like
Shoot , Jump etc..

i have no clue about how the implent the Math behind it
i remmember something about Cos/Sin/Tan but dont remmber what about it , if you can help , pls :*)
entomophobiac
21
Years of Service
User Offline
Joined: 1st Nov 2002
Location: United States
Posted: 5th Apr 2010 20:20
What calculations are you after? What should they do, in the end?
haliop
User Banned
Posted: 5th Apr 2010 20:35
shoot -> can move +1 from "gun" towards the player
but i think it should be sin/cos angle and speed
the "bullet" is shown so no raycasting
aim -> same just not the actuall shot just to aim from Enemy position to player position

jump - > jump up or sideways
haliop
User Banned
Posted: 5th Apr 2010 20:36
i bought a book about 3d Math , but i dont think i will finish it or get to that part cause it got it all from ground up , but i have until the end of april to finish this project, so its a slow read while making this game / modeling and learning blender / learning how to draw rich enviorment textures using gimp.. and learnig 3d math.. bahh (i guess it will be rewarding at the end)
_Pauli_
AGK Developer
15
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 5th Apr 2010 20:55 Edited at: 5th Apr 2010 20:57
I have not that much experience with 2D,
but you might consider doing this with vectors.

Like you could get a vector enemy-player (e.g. EP) when enemy shoots:
EP = EnemyPos - PlayerPos

Then you could move the bullet by let's say a tenth of this vector:
BulletPos += EP * 0.1

That should move the bullet in the direction of the player and you don't have to deal with sin/tan/cos at all.
The drawback is that you will have to find a way to make the bullet move at a constant speed, no matter where the enemy was when it shot (because it will result in different lengths of EP).
Just a thought to get you on the right track. I might be very wrong...

EDIT:
Oops, just saw that you didn't mention 2D at all, but it should be almost the same for 3D...

Now the plot thickens, the fps decreases, and the awesomeness goes through the roof.
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 5th Apr 2010 22:56 Edited at: 5th Apr 2010 23:00
Since its a side scroller the math wont be as complicated as it is 2D really.

I will presume your game is left to right -X to +X and up and down is +Y to -Y.
This means that you are interested in the Z angle rotation of your objects(bullets).
Its something like this, can't be sure without testing:



Set your bullets angle about the Z-axis to this and it should be facing the enemy, if not, tell me what happens.

haliop
User Banned
Posted: 6th Apr 2010 00:29
ok ty , i will check it.
CrazyCoder
14
Years of Service
User Offline
Joined: 30th Mar 2010
Location: Great Britain
Posted: 9th Apr 2010 21:19
For jumping you could have YPos and YSpeed.
When they are in mid air you add to YSpeed and then add YSpeed to YPos.
Like this:

In a side-scroller the ground level will change depending on the X position
but I've just set it as 440

Login to post a reply

Server time is: 2024-10-05 14:02:50
Your offset time is: 2024-10-05 14:02:50