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.

DarkBASIC Discussion / Finally I cracked it! 2D rotatable objects with vertices

Author
Message
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 23rd Jan 2008 02:32 Edited at: 23rd Jan 2008 02:34
Ok so you can't add an image or anything fancy like that but now I can make a gta style game with DBC! ehem, I mean like Asteroids


Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 23rd Jan 2008 08:29
Pretty Smooth!

Enjoy your day.
demons breath
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 23rd Jan 2008 15:19 Edited at: 23rd Jan 2008 15:19
That's pretty cool!

I just use newxvalue and newzvalue, like this:



that's part of what I have for some asteroids clone I'm trying to make; I find it much easier than fiddling about with vertices (don't understand them)...

Hopefully I should learn how to use vertices soon 'cos they're the next topic in my maths course so once I have the basics I'll give them a whirl, I'm just too lazy to learn anything new unless it's absolutely necessary...

"A West Texas girl, just like me"
-Bush
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 23rd Jan 2008 17:50 Edited at: 23rd Jan 2008 23:35
@DB
I've never used newvalue, now I see they are useful
I'm sure there are benefits from doing it the hard way like, ermm...

[edit]
Here's my next project
If I can make this in 2D I can make anything!

I'll have to position 63 vertices!

Can you guess what it is yet?

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 24th Jan 2008 00:06
I remeber doing a benchmark once and newxvalue etc were faster than sin and cos.

But you can squeeze a little more speed out of cos and sin that should leave sin() and cos() functions in the dust (newx etc too). Create lookup tables for sine and cosine. Here's a quick benchmark of sin() vs sine#() lookup:



It's about 200% faster on my computer. This only returns whole number angle ratios, but that should suffice.

Enjoy your day.
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 24th Jan 2008 01:58 Edited at: 24th Jan 2008 02:10
I took your advice but it's getting a bit messy.
This example also shows that all vertices no longer have to be connected.


demons breath
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 24th Jan 2008 20:46
@OBese: looking good, but it tends to spasm uncontrollably when it reaches the limit...

"A West Texas girl, just like me"
-Bush
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 24th Jan 2008 22:24
Yeah it's supposed to never actually seen that in real life but it happens in computer games

Link102
20
Years of Service
User Offline
Joined: 1st Dec 2004
Location: On your head, weeeeee!
Posted: 25th Jan 2008 12:18
instead of angle and distance, why don't you do xoffset and yoffset. That's how 3d objects work.

Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 25th Jan 2008 19:24
@link
Then I'd have to calculate the offset as the object rotates, but it would mean that when the object wasn't rotating I wouldn't have to calculate anything.
X and Y positions would also make it easier to detect collisions, maybe I'll try it.

Login to post a reply

Server time is: 2025-06-04 01:52:50
Your offset time is: 2025-06-04 01:52:50