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.

AppGameKit Classic Chat / Map Data for a racing game

Author
Message
anwserman
13
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 17th Jun 2012 08:40 Edited at: 17th Jun 2012 08:41
Hey everyone,
It's been a long time posting, but I finally got the hankering to start programming again! Anyway, I'm trying to figure out how I can stream map data into my Tier1 racing game during runtime.

This typically wouldn't be an issue (as I have made a couple apps before), but as it's a racing game, it's the size of the data that concerns me. The app I'm making is styled after Rad Racer on the NES. Using some basic math in my mind, to make an (average) stage last for 3 real-time minutes, I need to store 17,800 lines of map data.

This is a LOT of data to run through. As I'm targeting mobile devices, I'm not sure the best way to do this. Should I stream from the file by using a constant open file ID, or should I throw all of it in an array?

The data will be formatted approximately as:


To reduce file size, I plan on putting all data in the header of the map (ID:0,N,N,N,0,x,y) and then just refer to it by ID within the rest of the file (why have 17,800 lines of unnormalized data, sigh)

Comments, suggestions?.... For my other projects, I did use sizable arrays to store data, but that was a simple integer being stored. I'm afraid of attempting to use UDT's on such massive amounts of data and watching it crash and burn

Hi there. My name is Dug. I have just met you, and I love you.
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 17th Jun 2012 09:54
What does the "N" stand for? I assume the "object" values are a sprite or something like that?

-- Jim
anwserman
13
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 17th Jun 2012 10:05 Edited at: 17th Jun 2012 10:11
It's just a placeholder for data. It could be anything, for instance N could mean blank, or nothing. When running the map, reads what's furthest away (line by line). Think of it as going through a sequential list of data, moving the cursor line by line. So if it reads in a new line for the map, let's say it finds a C instead of an N, it knows to spawn off a car in the distance.

Hi there. My name is Dug. I have just met you, and I love you.
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 17th Jun 2012 10:40
Okay - so what's the range of X / Y adjustment values, and what's the range of values in the lane fields? I'm looking at ways of compressing this data. Unless they are all unique, you could, for example, simply index into a much smaller array.

-- Jim
anwserman
13
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 17th Jun 2012 11:22
At Jim, I was thinking of using a lookup table. The only issue I have with trying to compress the data into the app would be trying to edit it after compression (e.g., think about editing keyframes in Adobe Flash and screwing up and having to redo the entire tween).

Well, beyond that I think I found a bug in AppGameKit It never returns the value of the first token in a string. Aah well.... I'll post a video showing my current progress.

Hi there. My name is Dug. I have just met you, and I love you.
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 17th Jun 2012 11:58
@answerman - build the data outside the app, then process it into the compressed format. You won't want to do this using AGK. That way you always have your "source" to modify - build the compressed database, and off you go.

Am I right in thinking that your X Y offsets are relative to the current map node you're in? In that case, they're probably quite small values, and possibly repetitive. Unless your cars can reverse (?) you will always be stepping forward to the next node.

What can the values in the three track fields be? Let's say they are (empty,car,dog,bicycle). That's four possible values for each of three fields. So, since each field can be expressed as 2 bits, the maximum combinations is 6 bits, which means that all combinations can be packed into one byte - or one CHAR.

The same kind of rules could well apply to the offsets and the border object indices.

Like this kind of challenge!

-- Jim
anwserman
13
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 17th Jun 2012 11:58
http://www.youtube.com/watch?v=caozOzPg30s

Here's a video of the latest work. Anyone know how/why the objects seem to be distorted when they get close to the screen? The objects on the sides seem to slow down, and the lines in the road look funny.

(I scaled them from small to very big and I figured that'd work with lines on the road but I was wrong :/)

Hi there. My name is Dug. I have just met you, and I love you.
anwserman
13
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 17th Jun 2012 12:20
Quote: "@answerman - build the data outside the app, then process it into the compressed format. You won't want to do this using AGK. That way you always have your "source" to modify - build the compressed database, and off you go.

Am I right in thinking that your X Y offsets are relative to the current map node you're in? In that case, they're probably quite small values, and possibly repetitive. Unless your cars can reverse (?) you will always be stepping forward to the next node.

What can the values in the three track fields be? Let's say they are (empty,car,dog,bicycle). That's four possible values for each of three fields. So, since each field can be expressed as 2 bits, the maximum combinations is 6 bits, which means that all combinations can be packed into one byte - or one CHAR.

The same kind of rules could well apply to the offsets and the border object indices.

Like this kind of challenge!
"


I'm currently using Tier1, so I cannot choose smaller datatypes. Right now everything is stored as an Integer, except for the last two values which are stored as floats.

And you are correct. Each number (1, 2, 3, etc.) would relate to a different object. For the left and right sides, it would be a tree, a checkered flag, a rock, a person (heh). Almost anything that I could throw on the side of the road. Since colliding with ANYTHING would cause an error, all I need to do is just supply an image and I'd do the rest.

As for the lanes, I can only think of a couple values. 0 = regular lane, 1 = spawn car, 2 = checkpoint (add time), 3 = finish line.

As for the last two values, X and Y, they just 'skew' the field to make it look like the car is turning or going up/down hill. The values are global - not relative - and so they stay small.

Just currently testing in notepad, I'm just copying and pasting rows and running it at runtime, but I cannot deploy to my iPhone to test it out (yet), so I'm not sure how it works on mobile. Plenty of work left to do, but I think beyond having a skewed perspective with the rendering, that for one day's work, it looks fine

Hi there. My name is Dug. I have just met you, and I love you.
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 17th Jun 2012 12:41
Video looks great.

You can use smaller integer data types, if you remember that a string is actually an array of byte unless the system is Unicode in which case it's an array of smallint (16-bits).

-- Jim
bitJericho
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 18th Jun 2012 14:03
I was looking into loading chunks of map data and rendering them as needed for extremely large maps. I don't know yet if this is feasable as I haven't gotten that far yet

For a fast game like a racer, I dunno if this would be possible.

That said, a ginormous map of tiles, done right, doesn't use up much memory. You could keep the entire map in memory in most cases. AppGameKit can keep about 20k tiles active before it starts stuttering, so you would have to change out sprites quite a lot depending on what you're doing.

Login to post a reply

Server time is: 2024-11-23 17:29:56
Your offset time is: 2024-11-23 17:29:56