PDA

View Full Version : PGDmC: 2-bit Racer



Ingemar
02-07-2011, 06:33 PM
It is getting late, but now I think I can get far enough to believe that I will finish so this can be an entry in the challenge, and I am far enough for an early screen shot too. My game project is called "2-bit Racer", and the idea is simple: Make a racing game controlled by only 2 buttons. That is hardly a stroke of genius, but rather a simple idea along the lines of the challenge.

Here is a screen shot of the latest test version:

http://www.ragnemalm.se/images/2BRprel2.jpg

As you can see, the terrain is fairly nice, multitextured, and the car drives on it almost reasonably. The car texture is a placeholder. The 2-button control works fairly well. A skybox is in place. Engine sound works too, pitched according to speed.

I use no public game engine, only my own routines on top of OpenGL and OpenAL, some parts from my 2D engine, some parts of my incomplete 3D engine. The car model and the skybox are the only material from others (both from sites with free resources on the web). Uses FPC and Lightweight IDE on a MacBook with OSX.

Left to do: A lot.

- Improved physics. It is incomplete now.
- Collision detection! This is the biggest problem. I will have to make a simple solution for it.
- Put more objects into the game.
- Work on textures and tracks.
- Start/goal and checkpoints.
- Opponent cars with AI.
- Optimize for speed using VBOs etc.

Can I do that in the little time left? Well, I hope I can make some kind of decent playable demo/alpha of it before the challenge ends.

paul_nicholls
02-07-2011, 11:40 PM
Sounds like a good game, but the picture hasn't shown up for me :(

cheers,
Paul

Jimmy Valavanis
03-07-2011, 04:15 AM
The picture hasn't shown up for me too, interesting idea, only 2 button racing game. The two button keys are accelerate/brake or turn left/right?

Ingemar
03-07-2011, 06:34 AM
Just after I uploaded, the server went down at my web hotel, and it still isnt up, so let's upload it as attachment instead.

Concerning controls, it is one for right (with half thrust), one for left, both to thrust forward at full power. It works pretty well, but you can't take tight turns.

code_glitch
03-07-2011, 10:10 AM
Looking good. I'm seeing a lot of this 3d stuff coming out in the PGD challenge... I have to admit I always put my 3D engine research and experimentation to low priority...

Perhaps I should get back to it some time for PGD annual - still looking at file formats from which to load my 3D data :D

Ingemar
03-07-2011, 10:43 AM
Looking good. I'm seeing a lot of this 3d stuff coming out in the PGD challenge... I have to admit I always put my 3D engine research and experimentation to low priority...

Perhaps I should get back to it some time for PGD annual - still looking at file formats from which to load my 3D data :D

3D is a lot harder than 2D, and there is nothing wrong with 2D games, they are just as fun as long as the gameplay works. 3D has many problems, creating and storing 3D models being one very serious issue. I use OBJ files for models, which is limited (no bones, no animation) but fairly easy to manage. At the beginning of this project, I spent some time on 3ds loaders but it would take too much time to finish. We can get back to that later.

I actually first considered making this in 2D, but since I have worked with terrain generation before I had some partial solutions that I could use, and making my own 3D game of it has been on my wishlist for a long time.

Ingemar
03-07-2011, 08:07 PM
Just in case you wonder, the skybox is from here:

http://www.tutorialsforblender3d.com/Textures/Skys/Sky_Box_1.html

I have tried making my own skybox using Terragen (Mac version) but I get seams. :( I think I accidentally cause them when assmbling one single picture out of the separate parts.

The car - which now has its nice original texture - comes from here:

http://www.turbosquid.com/Search/Index.cfm?keyword=&media_typeid=2&search_type=free&file_type=119&page_num=1

Ñuño Martínez
06-07-2011, 07:41 AM
Reading "2-bit Racer" I spected a very different screen shot. :D

I'm trying to imagine how to control the car using only two buttons, and I had some interesting ideas. I want to see which one your game uses.

Ingemar
06-07-2011, 06:22 PM
Reading "2-bit Racer" I spected a very different screen shot. :D

I'm trying to imagine how to control the car using only two buttons, and I had some interesting ideas. I want to see which one your game uses.

And now you make me wonder what you expected. :)

Traveler
06-07-2011, 06:53 PM
I think something in black and white? Tbh, I had a similar thought.

Ingemar
06-07-2011, 08:47 PM
I think something in black and white? Tbh, I had a similar thought.

Yes, that would be a possibility, as in graphical bits, e.g. using toon shading. But I referred to bits of control.

code_glitch
07-07-2011, 05:54 AM
I have to admit, from the name it sounds like 4 bit color/grey...

Ingemar
07-07-2011, 06:55 AM
I have to admit, from the name it sounds like 4 bit color/grey...

Maybe I should call it "2-button Racer" then?

WILL
07-07-2011, 07:09 PM
Well technically with 2 bits you can count from 0 to 3... so that's 4 states. :P

paul_nicholls
07-07-2011, 08:52 PM
Well technically with 2 bits you can count from 0 to 3... so that's 4 states. :P

:D he's got you there Ingemar, but name it what you want - still sounds cool :)

cheers,
Paul

Ingemar
11-07-2011, 01:16 PM
A little status report:

- Collision detection is now really good. I have experimented with stationary objects and it works well, quite stable.
- Camera placement is now decent. For quite some time the camera kept catching up with the car which looks bad.
- I have done some work on my own models. Sadly, I am no 3D artist so they are either simple or look terrible.
- Start/finish/checkpoints, not finished but soon. Maybe working this evening.
- Work on level data files.

Left to do:
- Make the checkpoints work properly (and related game mechanics).
- Computer players with decent AI.
- Particle system for smoke.
- Better sound effects. (cfxr is a great tool, but the sound quality is not always ideal.)
- Optimization through VBOs and frustum culling. I will probably skip that for now as long as it runs fine on my MacBook.
- Make it fun to play. :) Really the hardest problem of all.

The biggest critical problem still unsolved is how to make AI players, and I really need that. But anyway, for being a 3D racing game that is not built on any 3rd party engine, I am rather happy.

paul_nicholls
11-07-2011, 08:58 PM
Sounds great Ingemar, keep going mate :)

cheers,
Paul

Ingemar
14-07-2011, 10:34 PM
Sounds great Ingemar, keep going mate :)

Thanks! Sadly, that's exactly what my game AI's does not do right now. They get stuck. Oh well, they are the latest addition so I just have to figure out a few more rules for them to follow.

Ingemar
16-07-2011, 07:15 AM
Test upload made! It is called "2-bit racer test 1.zip" and is a binary for Mac OSX 10.6.

The game looks a bit strange since the cars have no wheels, but otherwise it is getting close now. The game AI works, it is not very good but it is possible to perform a full race, currently with two opponents. A full race is three laps.

Linux/Windows version? Well... no. I won't have time. Most of the code is fully portable, especially to Linux, and to Windows shouldn't be hard, but I don't have time for that. Most critically, I don't have any Windows development system with FPC that I am comfortable with. But if someone would like to help me with that, it might be easy.

Ingemar
16-07-2011, 10:43 AM
I just tested the game on two other Macs, with less than pergfect results. The other Macs are older, have less powerful GPUs. On an old MacBook, with GMA950, I could make it run once I turned off the shaders, and even then it ran less than smooth.

But I believe that the judge's Macs were rather better than my main MacBook, and then it should work just fine. I better upload a shader-free version just in case. It doesn't look as good but the chance of running at all improves a bit.

chronozphere
16-07-2011, 12:01 PM
AI can be really tricky in these kinds of games. If you are using a 3d environment you will probably need to set out invisible waypoints or some other datastructure to "guide" the AI. This can take a lot of time to fine-tune.

And yes, making it a fun game is allways the hardest part. I've written two games in pascal and while they both worked great, they were still not well-balanced and still miss that replay value a good game needs.

Good luck (You'll need it) ;)

Ingemar
16-07-2011, 02:54 PM
I am soon ready to make another upload, with a whole bunch of fixes, but it would be really interesting to know if anmyone out there with a fairly modern Mac can run the game. Anyone?

Ingemar
16-07-2011, 07:50 PM
I realized something unpleasant but important: The speed of my game was not limited by my timer but by my CPU. That means that other Macs can work very, very differently. In order to fix that, I fixed the worst bottleneck (Immediate Mode code). The whole game went VA-VA-VOOM and got totally unplayable - but really smooth. So now I have to re-tune the whole mess.

I knew all along that Immediate Mode wasn't an good idea, but the difference was bigger than expected.

WILL
16-07-2011, 08:37 PM
Yeah one of the more important parts of making a game is the timing of your 'frames'. I'm not talking graphical frames per-say, but your game's running frames. Each update of your game objects and environment. This is key to a nice running game.

Ingemar
17-07-2011, 05:43 AM
Yeah one of the more important parts of making a game is the timing of your 'frames'. I'm not talking graphical frames per-say, but your game's running frames. Each update of your game objects and environment. This is key to a nice running game.
That is certainly the case and I should have planned for it. There should always be a "dt". But the other way to do it, which was how I did it, is to lock the frame rate and work from that. Sadly I didn't notice that I got less than the planned fps. It wasn't exactly hard to see, 11 fps instead of 50, but you quickly get used to 11 fps.

But I will fix that now.

Ingemar
17-07-2011, 07:04 AM
Phew, now it looks better, running at a steady 50 fps with decent response which should be fps independent. Now I can focus on improvements, tuning how much the AIs should cheat etc.

Jimmy Valavanis
17-07-2011, 07:19 AM
Unfortunatelly I don't have a MAC to run your game, can you post a screenshot of the latest version??

Ingemar
17-07-2011, 10:16 AM
Unfortunatelly I don't have a MAC to run your game, can you post a screenshot of the latest version??

Right, new screen shot:
http://www.ragnemalm.se/images/2br.jpg

I also uploaded the current version to the FTP site.

Ingemar
17-07-2011, 02:42 PM
I just uploaded the (first) final submission version of 2-bit Racer.

Now, there is one thing I wonder: What would you consider the fastest way to build a Windows version? I am not up to date on Windows or Linux tools. Under Windows, I used to compile FPC programs by drag-and-drop, worked pretty well. But in this case, I must also link with OpenGL and OpenAL.

Ingemar
17-07-2011, 08:27 PM
After submitting, I have worked on a music score, and I also thought I would make another track or two... but that will have to wait, I guess. And with a music score, it will be less portable since I am using QuickTime for playback. But what I really wanted to do was to make a Windows or Linux port, but my Linux installation is broken and I find it hard to work under Windows (not least since that damn PC has such a noisy fan, you can imagine how fun that is when you are used to near silent computers).

But I must help the kinds going to bed, so... I hope my upload is complete and well, nobody seems to have tried it yet.

czar
17-07-2011, 11:50 PM
I don't see a link. You mention an FTP site but where do I find that?

paul_nicholls
18-07-2011, 02:40 AM
Right, new screen shot:
http://www.ragnemalm.se/images/2br.jpg

I also uploaded the current version to the FTP site.

Looking good :) So what does HEJDA mean?

cheers,
Paul

Ingemar
18-07-2011, 05:32 AM
Looking good :) So what does HEJDA mean?

It means "bye-bye", a message to cars behind.

Ingemar
18-07-2011, 05:33 AM
I don't see a link. You mention an FTP site but where do I find that?
That was to the competition FTP site, but I also uploaded it here:

http://www.ragnemalm.se/lightweight/2-bit%20racer%20submission.zip

Ingemar
18-07-2011, 05:44 AM
A little project summary:

- Writing games in FPC is great fun, and can be done quite efficiently if you are focused.
- Use the modern features of FPC to your advantage! We have the best programming language but only if we use it properly.
- Game physics is hard. If you try faking it, the shortcuts get highly noticable.
- Game AI can be tricky too. It can often be hacked, but then it gets pretty dumb.
- 3D requires a lot of tools, but once you have a decent set of tools (3D modeler like Wings 3D or Blender, paint program like Pixelmator, model loading code, texture loading, linear algebra code, collision detection) then 3D is managable.
- One reason for me to write this was to make a project like the ones my students do. I don't want to get stuck teaching but never doing, only telling people to do fun things but never doing them myself. You always learn by doing.
- Trenkti y g??rble!

paul_nicholls
18-07-2011, 06:34 AM
It means "bye-bye", a message to cars behind.

haha! cool :)

Jimmy Valavanis
18-07-2011, 07:50 AM
Unfortunatelly I don't have a Mac to play your game :(, but the source code seems very portable thanks to the GLU and GLUT :)

Ingemar
18-07-2011, 07:55 AM
Unfortunatelly I don't have a Mac to play your game :(, but the source code seems very portable thanks to the GLU and GLUT :)

Yes, and that is intentional. That's why I considered making a port in the last minute (although I havn't done it yet). It is just FPC, OpenGL and OpenAL, all portable. Minimal dependencies, I even use TGA instead of PNG to be independent of zlib.

Ingemar
18-07-2011, 01:40 PM
A little project summary:

- Writing games in FPC is great fun, and can be done quite efficiently if you are focused.
- Use the modern features of FPC to your advantage! We have the best programming language but only if we use it properly.
- Game physics is hard. If you try faking it, the shortcuts get highly noticable.
- Game AI can be tricky too. It can often be hacked, but then it gets pretty dumb.
- 3D requires a lot of tools, but once you have a decent set of tools (3D modeler like Wings 3D or Blender, paint program like Pixelmator, model loading code, texture loading, linear algebra code, collision detection) then 3D is managable.
- One reason for me to write this was to make a project like the ones my students do. I don't want to get stuck teaching but never doing, only telling people to do fun things but never doing them myself. You always learn by doing.
- Trenkti y g??rble!

Oh yes, two more conclusions:
- I got up to speed with Wings3D again and learned how to do texture mapping with it (which wasn't supported in the past).
- I learned about Cfxr, nice little utility.

Traveler
18-07-2011, 07:05 PM
Sadly I cant play your game either. I wanted to make it a point to try and play the games you all made, but in this case I cant. Perhaps you or someone else is able to create a video so we can at least see your game in action?

Ingemar
18-07-2011, 08:44 PM
Sadly I cant play your game either. I wanted to make it a point to try and play the games you all made, but in this case I cant. Perhaps you or someone else is able to create a video so we can at least see your game in action?

I'll try to make a video. However, it should be piece of cake to port it to Linux or Window with a computer with FPC installed. I might do that myself, but there is a startup time on that for me. (And I am also a bit busy trying to add the music.)

Ingemar
19-07-2011, 06:38 AM
Now with music: http://www.ragnemalm.se/lightweight/twobitracer-with-music.zip

and a video: http://www.ragnemalm.se/lightweight/twobitclip.mov
(A bit weak sound, short part of a race.)

Ingemar
19-07-2011, 07:21 PM
I tried making a Windows port today. Big surprise, it is always harder than you expect. I use Unix file handling calls (FpOpen, FpRead etc) for TGA loading and OBJ loading, and replacing them with standard Pascal calls turned out to be pretty hopeless. FpRead just doesn't map well on Read, not even BlockRead. I might have done something wrong but BlockRead messed up my data badly.

So I should probably give up the portability ambitions for now. :( Really a pity since that is a major reason for using OpenGL. A Linux port would be much easier though.

Traveler
19-07-2011, 07:52 PM
Too bad about the conversion. But, thanks for putting up the video.

Ingemar
06-08-2011, 10:10 AM
Speaking of my conversion, there were two problems: I did try to remap the file functions, and was partially successful, but then we have the other problem: Playing sounds. I use QuickTime on the Mac, and although QuickTime exists for Win32, it won't help for Linux and I never used it on Windows, so there can be any number of problems.

What do the rest of you use to play music under Windows?

paul_nicholls
06-08-2011, 11:37 AM
There is always SDL DLLs (http://www.libsdl.org/), and freepascal comes with SDL units already.

cheers,
Paul

Ingemar
06-08-2011, 08:58 PM
Aren't there any extensions to OpenAL for playing music?

paul_nicholls
06-08-2011, 10:34 PM
OpenAL works out of the box for sound effects, but if you want play stuff like ogg files you need some extra units and dlls I think.

See here for a C++ tutorial on ogg streaming:
http://www.devmaster.net/articles/openal-tutorials/lesson8.php

There is a Delphi translation at the bottom of the page

cheers,
Paul

Traveler
07-08-2011, 09:42 AM
I used bass (http://www.un4seen.com/) for my entry. It's free for non commercial games, which makes it a great choice for competitions like the one we had.

Ingemar
07-08-2011, 04:04 PM
I used bass (http://www.un4seen.com/) for my entry. It's free for non commercial games, which makes it a great choice for competitions like the one we had.
And cross-platform too, nice. Never heard of it but it can be worth a try. FPC interfaces? Or is that trivial?