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.

2D All the way! / GTA 1/2 style

Author
Message
TheCyborg
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Denmark
Posted: 7th Oct 2002 06:04
I would like to create some sort of gta 1/2 top-down racing game.

I'm using a sprite annimation for my car, wich currently have 8 dirrections. I will make it to 16 or even 32 dirrections.
I know how to control the sprite in 8 directions (with acceleration & decceleration) in the dirrection of my cursor keys.

But how do i make the upkey to a speeder, downkey to a brake and left- & rightkeys for smooth turnings?
Please Help...

PS: If I'm bad spelling, It's because I'm from DK.
"It's good to be bad..."
Dungeon Keeper
Zero
21
Years of Service
User Offline
Joined: 28th Aug 2002
Location: Finland
Posted: 7th Oct 2002 11:25
GTA 1/2 are in 3d. You will get pretty flat and small city in plain 2d. 3D cities (made out of boxes as buildings) gives you a depth in spite of cars are just 3d-planes/sprites in GTA 1/2.

I'm saying that making a game such as GTA 1/2 is easier and more flexible to be in 3d.

The evil plan is now even closer!
- - - - - - - - - - - - - - - - - - - -
Specs:- P3 550 Nvidia TNT2M64, 192Mb RAM
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 7th Oct 2002 15:13
Zero's right, GTA 1/2 though they look 2D it was actually Sprite Plains on a Simple 3D Matrix with Simple Box Buildings ... something DBpro is actually far better suited to

This will not only make everything much simpler to build, however it will also mean all the animations can be FAR less. DBpro support alpha images now right?
As that'll help blend it all better
(where is DK btw?)

Holy jumping mother of god NOOOO!!!...
Ahem I mean, I'll think about it
Richard Davey
Retired Moderator
21
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 8th Oct 2002 01:09
Actually I'm going to contradict the advice given here so far and say continue using sprites - and look into the "rotate sprite" commands because you can make a car driving around and rotating smoothly very easily using this and you do not have to draw 8 (or 16, or 32 or whatever) different angles of the car.

Cheers,

Rich

"Gentlemen, we are about to short-circuit the Universe!"
DB Team / Atari ST / DarkForge / Retro Gaming
The Darthster
21
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 8th Oct 2002 02:34
To do acc/brake and turning, use this:
On upkey, increase the velocity by a factor of 1/valocity to prevent you speeding up too much, and do kind of the same thing with the brake. To turn, use left and right keys to increment and decrement an angle variable. Then when updating the sprite, use rotate sprite with your angle variable, and move sprite by the velocity. If you use rotate sprite, make sure to offset it by half, as it rotates around the top left corner of the sprite.
TheCyborg
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Denmark
Posted: 10th Oct 2002 20:34
I've got another problem. I'm using DB v1.13, but in this version there are NO Sprite rotation commands. And i know that Gta 1/2 actually was 3D, but the cars was some sort of 2D sprites. My game will also be in 3D (with 2D Cars) if it's ever going to be finished.
I'v got the acc/Brake thingy now, but still need the turning. What do i do?

PS: DK is short for Denmark (not a state) it is in scandinavia (with sweeden and norway, you know).

"It's good to be bad..."
Dungeon Keeper
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 11th Oct 2002 09:59
hehee...
i see Rich playing the "use the sprites" again.
quick point here, the cars were quads with a transparent texture - it was mostly used to actually not have to animate much and keep the shape, but in Dx8.1 sprites are really 3D anywas so wouldn't make much odds.
Only reason for suggesting 3d over 2d is if you go with 3D cities... it is gonna be a buggar to position and give the illusion of height properly with a sprite without actually putting alot of effort into where the car SHOULD be on the 3D city.

I mean your decision, and be interesting to see which path you choose - as both have thier advantages

if your using 1.13, then i'm gonna hazzard a guess you have memblocks - now this won't be pretty but you'll have to use a memblock to setup a rotation equasion (don't look at me i'm useless with 2D equasions of that nature) - otherwise you'll have to i dunno, convert to bitmap rotate that way and convert back each time ... or you could just download dbpro demo

Holy jumping mother of god NOOOO!!!...
Ahem I mean, I'll think about it
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 11th Oct 2002 15:19
Hey Cyborg,

I have a little GTA 1/2 engine you could look at - has a man walking about and a car he can get into, and obviously a couple of buildings and streets - all in glorius top down 3D, the 2D sprites are rotatable because they're just plains, there's even some makeshift collision detection and map design principles.

You want? - let me know and I'll email it to you.


Van-B
TheCyborg
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Denmark
Posted: 15th Oct 2002 01:29

To Van B!
I would really like to have your little engine. Just send it to my E-Mail. Just what I needed.
Thanx.


To Raven Vegeta!
DB 1.13 do have memblocks. But I do not what they are for and how to use them.
I'll downloaded the DBPro trial. But it's not the same. Then I have to make the complete game in 30-days.

"It's good to be bad..."
Dungeon Keeper
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 15th Oct 2002 12:42
NP Cyborg, I'll email it tonight - but I need your email address, if you'd rather not post it - email me: vanbsoftware@hotmail.com.


Van-B
TheCyborg
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Denmark
Posted: 15th Oct 2002 14:36
Down under every post there is a link to the email.
If you don't see that then my mail is:
SimonBundy@the-pentagon.com
Thanx again.

"It's good to be bad..."
Dungeon Keeper
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 15th Oct 2002 18:05
Ahh sorry, It only shows them when your logged in - I wasn't at first so I could'nt find your mail . I'll email it tonight (or in about 4 hours from now).


Van-B
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 15th Oct 2002 22:22
Source emailed, hope it helps.


Van-B
TheCyborg
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Denmark
Posted: 16th Oct 2002 01:20
This piece of source sure answered alot of my questions.
Thanx again.

TheCyborg

"It's good to be bad..."
Dungeon Keeper
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 16th Oct 2002 09:08
Hey thats my av... pretty sweet to see it full size in here
(oh and i remember it being posted in the RGT forums when my bro was on that it was stolen - so if anyone did look online for it then please tell me i need a good chuckle )

Memblocks are actually remarkably simple - what they are, are sections of memory where you store anything you choose and edit it within the memory itself. It has no difference in use over the File options, however it is undoubtably faster than files and arrays ... this gives it an advantage to be useful in so many ways!!

Most of the time I use them purely for Mesh and Image functions, where i need to rebuild both in realtime - suchas with my skeletal animation demo and lightmapping demo...

the actual coding it upto you and if you use them then you must specify how large they are - trying to remember you have a limited amount of Ram to actually use.

hope that answers your questions

Holy jumping mother of god NOOOO!!!...
The Darthster
21
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 19th Oct 2002 01:07
To rotate a sprite using memblocks, you can use a matrix. I think the 2d rotation matrix is:

[cos a# -sin a#]
[sin a# cos a#]

By mutltiplying each point by this matrix and putting the result in a memblock, you can rotate images around an origin. Your origin will be the centre of the sprite, so you will have to shift the image coordinates by half to get the proper rotation. I'll write some code that'll do matrix image rotation, right after I've finished my cartoon rendering program. Since I only have a geforce 2, I have to do the cartoon rendering by hand. Currently I'm trying to figure out rgb colour boundaries from a 2 byte number (65535). Can anyone help me with that?

Anyway, matrix rotation commands are in the 3dmaths command set in dbpro, but I can't figure out how to even start with them, every command I use gives me a 'could not understand command' error. I know how to use the 3d maths, but not the syntax for setting up the data types.

If you want more information just ask.
rodrigoFM
21
Years of Service
User Offline
Joined: 21st Oct 2002
Location:
Posted: 31st Oct 2002 04:52
i'm trying to do a game like GTA...
to move my char i used:
if downkey()=1 and i=1 then y=y+7
if upkey()=1 and i=1 then y=y-7
if downkey()=1 and i=2 then y=y+5
if downkey()=1 and i=2 then x=x-5
if upkey()=1 and i=2 then x=x+5
if upkey()=1 and i=2 then y=y-5
if downkey()=1 and i=3 then x=x-7
if upkey()=1 and i=3 then x=x+7
if downkey()=1 and i=4 then y=y-5
if downkey()=1 and i=4 then x=x-5
if upkey()=1 and i=4 then y=y+5
if upkey()=1 and i=4 then x=x+5
if downkey()=1 and i=5 then y=y-7
if upkey()=1 and i=5 then y=y+7
if downkey()=1 and i=6 then y=y-5
if downkey()=1 and i=6 then x=x+5
if upkey()=1 and i=6 then x=x-5
if upkey()=1 and i=6 then y=y+5
if downkey()=1 and i=7 then x=x+7
if upkey()=1 and i=7 then x=x-7
if downkey()=1 and i=8 then y=y+5
if downkey()=1 and i=8 then x=x+5
if upkey()=1 and i=8 then x=x-5
if upkey()=1 and i=8 then y=y-5
-----------
image 1 is headed up, 2-45 degrees to the right, 3- 90degrees to the right...

indi
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 1st Nov 2002 09:06
You may want to explore the scancode command for some easier writing of multiple keys and trapping one hit instead of unwanted rapid fire

indi is part of Team Lunarpixel
multimedia logisitics and interactive media
The Darthster
21
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 2nd Nov 2002 23:58
You may also want to use the newxvalue and newyvalue commands to work out your movement relative to an angle, and translate the angle into an image number to display the sprite. That would provide far smoother turning and movement.
Bogboy2000
21
Years of Service
User Offline
Joined: 8th Nov 2002
Location: United Kingdom
Posted: 10th Nov 2002 19:32
to RodrigoFM not very efficiant code better

if downkey()= 1
if i=1 then y=y+7
if i=2 then y=y+5 and x=x-5
if i=3 then y=y-7
if i=4 then y=y-5 and x=x-5
if i=5 then y=y-7
if i=6 then y=y-5 and x=x+5
if i=7 then y=y+7
if i=8 then y=y+5 and x=x+5
endif

and the same sort of thing with up

this organises the game for you to understand it more easily and the game doesn't check for down and upkey so often

rapscaLLion
21
Years of Service
User Offline
Joined: 29th Aug 2002
Location: Canada
Posted: 11th Nov 2002 02:13
heheh... this is really off topic but I love GTA... still play it!

Alex Wanuch
aka rapscaLLion
Get the DB Weekly Newsletter at www.dbwn.cjb.net
Programmer for Christ
21
Years of Service
User Offline
Joined: 15th Nov 2002
Location: United States
Posted: 16th Nov 2002 08:35
To Darthster:
Hey, I needed to convert between 24 bit and 16 bit color to change color in the memblocks and work with a bitmap.
These are two functions that take in the 16/24 bit color and output the changed.
I hope they help.



Basically RGB in 16 bit is:
Red - 5 bits -32
Green- 6 bits - 64
Blue - 5 bits- 32
They add to 16 bits

Login to post a reply

Server time is: 2024-04-25 12:41:13
Your offset time is: 2024-04-25 12:41:13