pouët.net

3d twisty track

category: general [glöplog]
Powerdrift = my favourite arcade game.
It's done with zoomed and rotated sprites, it's different from drawing a road line by line.
added on the 2008-11-08 21:48:59 by pmdata pmdata
BB Image
raCer (early alpha !)
:)
p.s.: plays best with PS2 pad (w/ USB adapter) but also playable via keyboard..
added on the 2008-11-09 23:57:22 by xyz xyz
it's printed on the console anyway but in case anyone wonders how to escape the inevitable "fall 2 death" at the beginning-- (hint: press 'r'..):

Code: Welcome to -= raCer =- (alpha 09Nov2008) Game Keys: r / JOY 'START' : Reset player and map left+right / JOY AXIS 0 : Turn left/right up / JOY 'X' : Accelerate down / JOY '[]' : Brake k / JOY 'R1' : Boost j+l / JOY 'L2' + 'R2' : Airbrake left/right (both=brake hard) JOY AXIS 1 : Nose up/down JOY AXIS 2 : Accelerate/Brake Other Keys: m : Toggle OpenGL multi-sampling (default=off) Debug Keys: i : Toggle springs (debug) c : Toggle debug cam (wasd+mouse) v : Draw collision triangles x : Draw force vectors z/y : Draw debug collision spheres f : Flip player (debug) BACKSPACE : Toggle fullscreen (1920x1200)


this game is a spontaneous (over-two-weekends) attempt to remake "wipeout" :)
physics need fine tuning (probably) but the collision detection should be quite ok now (press 'v' to watch the colliding triangles..)

the "map" is mostly procedural (2D path is loaded from .svg but height data, "twist" and "width" is calc'd via sin()..)

I wonder if this gameplay can be achieved (with even simpler graphics, of course) on an A500 or maybe an (accelerated?!) A1200 ;)
(the PC version is prototyped in a script language but most of the CPU time is eaten by the 3D rendering since the entire map vertexarray is redrawn each frame, i.e. occlusion culling still needs to be implemented)

cheers ;)
added on the 2008-11-10 00:35:49 by xyz xyz
Very nice! I've always wanted to re-create the first Ridge Racer for PSX. Maybe someday. I'm starting out small though hehe.
added on the 2008-11-10 12:49:11 by b0ib0t b0ib0t
yea, ridge racer was a nice game, too :) and do not over-estimate the effort: it's just ~2000 lines of code for the "racer" :)

according to my calculations, it is possible to do this on an unaccelerated a1200 @ 30fps (one frame for physics and screen clear via blitter, one for dot rendering/triangle ;))

it would probably look more like this:
BB Image

(to try it out in realtime, download this and replace "data.tkx" by this (rename it to "data.tkx" !) ,
after start press 'q' to select render mode (none, dots, tris) and use 'v' to toggle collision triangle drawing)


everything except rendering of the track takes ~0.75-1% CPU time on a single 2800Mhz Intel Core2 core, track rendering adds up a whopping 27% (spread to 4 cores, NVidia 8500GT passively cooled gfx card) although it is only a simple glDrawArrays() call in the script.. (suprisingly does not make a difference whether only dots or tris are rendered!)

an Amiga 1200 is clocked at 14Mhz so the code has ofcourse to be ported to "C" and the vector math has to be optimized with inline asm (and ported to fixmath..). I cannot exactly remember how many dots a stock A1200 can render in "one frame" but I guess its more than 1000. with some occlusion optimizations it should be possible to render (a subset of) the currently 16565 vertices (the number can be easily cut down to 4000-8000 by tweaking the bezier/casteljau recursion threshold)

..would probably beat stunt car racer gameplay-wise :-)
added on the 2008-11-10 22:49:25 by xyz xyz
I'm gonna try it out tonight. I've got a Quad Core 2.4ghz cpu. You gonna share the source code for this, or is it under wraps?
added on the 2008-11-11 18:04:25 by b0ib0t b0ib0t
Yep I guess I can share the source. It's written in "TkScript" but the syntax looks a lot like C/C++/Java so it should be easy to read.

(well, the source is not very clean and there are many places where I wrote-out the vector maths instead of using the Vertex/Matrix classes but what the hell ;))

here it is

p.s.: there is no license for the source yet, so keep it "private", i.e. please do not turn it into a java handy game right away ;)

p.p.s: if you want to toy with it, just unzip the files (.exe, .dll) from the first .zip and the source files into the same directory, open a console and "cd" to the directory, then run "tks racer" to start the .app
(.tkx files are "packages", similar to .jar for example, you won't need them if you have the sources)
added on the 2008-11-11 21:28:08 by xyz xyz
a wipeout remake?

BB Image

but yours look nice too =)
added on the 2008-11-11 22:34:31 by s0r s0r
haha, no, sir !

*this* is a racing game !1


BB Image

..oh wait...it's a fscking spoon ;)


srsly, I bought wipeout fusion back then having been a total fanb01 of wipeout 1 + 2(097) (and to a certain degree, 3) but fusion sucked big time me thinks..

I know my prototype game is far away from being a "wipeout" clone but maybe I'll tweak it a bit every now and then and some more gameplay code (ghosts, lap times etc..)
maybe. maybe it's just one of many toy projects that never get finished ?!
dunno. in its current state, it "sucks", I know, but it could evolve into a half-way decent free fun racer :^)
added on the 2008-11-11 22:47:19 by xyz xyz
hehe..i was just teasing ya a bit, i take every opportunity to brag about how great WipeOut HD is, coz .. it is.. best wipeout ive played since wipeout 1+2 and the psp versions , its beautifull in 1080p, 60fps fast and great fucking fun.
i encourage everybody to sell they wii and spend 15euro on this masterpiece.

and ofcourse 399 on a ps3 and 1200e on a 102cm fullHD bravia or similar lol

I LOV BRAGGIN! and wipeout.

peace and let us know more when u got more gameplay code.
added on the 2008-11-11 22:55:00 by s0r s0r
I don't think it sucks. I think its pretty solid!
added on the 2008-11-12 00:37:51 by b0ib0t b0ib0t
My latest progress...

[code]
#include <allegro.h>
#include <iostream>
#include <string.h>
#include <sstream>
#include <fstream>
#include <math.h>
using namespace std;

//SYSTEM SETUP GLOBALS
#define sysXres 1024
#define sysYres 768
#define sysBpp 16
BITMAP * gbmp;

int drawTrack(int fwdMomentum, int left, int right);
int systemInit();
int updateScreen();

int main(){
systemInit();

while(!key[KEY_ESC]){
drawTrack(0,0,0);
updateScreen();
//cout<<"OMG WTF!!!"<<"\n";
}
}
END_OF_MAIN()

int drawTrack(int fwdMomentum, int left, int right){
int tracksize = 430;
int linesize = 50;
int step = 0;
int x = 0;
int trackcolor = 0;
//move directions

//draw the track from the bottom up
for(int i = sysYres; i > (sysYres / 2); i--){

if(i % 5 == 0){
if(tracksize > 0){tracksize-=5;}
step++;
trackcolor = 150;
}

if(i % 10 == 0){
trackcolor = 100;
}

x = (mouse_x - 512) * step + 512;

hline(gbmp , x - tracksize , i , x + tracksize , makecol( trackcolor, trackcolor, trackcolor ));
}
}

//systems init; mouse, gfx, keys etc...
int systemInit(){
allegro_init();
install_mouse();
install_keyboard();
set_keyboard_rate(400, 0);
set_color_depth(sysBpp);
set_gfx_mode( GFX_AUTODETECT_WINDOWED, sysXres, sysYres, 0, 0 );
gbmp = create_bitmap(sysXres, sysYres); //HACK rows should render to their own bitmap, this is just a test
}

int updateScreen(){
//show_mouse(gbmp);
blit(gbmp, screen , 0,0,0,0,sysXres , sysYres);
clear_bitmap(gbmp); //removed because it was causing bug with backgrounds
}

[/code
added on the 2008-11-13 23:26:46 by b0ib0t b0ib0t
Code: #include <allegro.h> #include <iostream> #include <string.h> #include <sstream> #include <fstream> #include <math.h> using namespace std; //SYSTEM SETUP GLOBALS #define sysXres 1024 #define sysYres 768 #define sysBpp 16 BITMAP * gbmp; int drawTrack(int fwdMomentum, int left, int right); int systemInit(); int updateScreen(); int main(){ systemInit(); while(!key[KEY_ESC]){ drawTrack(0,0,0); updateScreen(); //cout<<"OMG WTF!!!"<<"\n"; } } END_OF_MAIN() int drawTrack(int fwdMomentum, int left, int right){ int tracksize = 430; int linesize = 50; int step = 0; int x = 0; int trackcolor = 0; //move directions //draw the track from the bottom up for(int i = sysYres; i > (sysYres / 2); i--){ if(i % 5 == 0){ if(tracksize > 0){tracksize-=5;} step++; trackcolor = 150; } if(i % 10 == 0){ trackcolor = 100; } x = (mouse_x - 512) * step + 512; hline(gbmp , x - tracksize , i , x + tracksize , makecol( trackcolor, trackcolor, trackcolor )); } } //systems init; mouse, gfx, keys etc... int systemInit(){ allegro_init(); install_mouse(); install_keyboard(); set_keyboard_rate(400, 0); set_color_depth(sysBpp); set_gfx_mode( GFX_AUTODETECT_WINDOWED, sysXres, sysYres, 0, 0 ); gbmp = create_bitmap(sysXres, sysYres); //HACK rows should render to their own bitmap, this is just a test } int updateScreen(){ //show_mouse(gbmp); blit(gbmp, screen , 0,0,0,0,sysXres , sysYres); clear_bitmap(gbmp); //removed because it was causing bug with backgrounds }
added on the 2008-11-13 23:27:03 by b0ib0t b0ib0t
BB Image

Ok, here's a new release.
After that, I guess I will be quiet for a while, add the promised "gameplay code" and optimize the gfx rendering :-)

this release greatly improves ship handling and the camera.
I also added "walls", which can be activated by pressing 'i' resp. L1 on a PS2 pad (via "center" usb adapter).

have fun !

added on the 2008-11-16 22:09:37 by xyz xyz
Very nice!

I took a break, no coding this weekend. Maybe I'll work on making mine something playable.
added on the 2008-11-16 22:38:16 by b0ib0t b0ib0t
Reminds me of a certain 32kb game by calodox...
added on the 2008-11-16 23:08:55 by xernobyl xernobyl
xrl: thanks for the link, I almost forgot about el loco megabus ! :)
well, this game is currently 19k
(if you do not count the platform -- like you would do with flash, alambik or javascript demos/games..)

:-)
added on the 2008-11-16 23:17:57 by xyz xyz
(19k of tokenized, compressed source code, that is ;))
added on the 2008-11-16 23:21:14 by xyz xyz
...and greetings to Cubic Team, especially Nils, who explained the Casteljau Bezier algorithm to me in the beginning ;)
added on the 2008-11-17 00:28:44 by xyz xyz
fantastic, it places my ship all the time outside the track and i can'd do nothing but fall. :(
added on the 2008-11-17 10:14:54 by kelsey kelsey
press 'return' to reset the player
added on the 2008-11-17 13:52:57 by xyz xyz
Quote:
...and greetings to Cubic Team, especially Nils, who explained the Casteljau Bezier algorithm to me in the beginning ;)


Perhaps you can pass this on to me? ;)
added on the 2008-11-17 15:00:16 by b0ib0t b0ib0t
b0ib0t: you already have the source for this ! (file name is bezier.tks!)

For a more detailed explanation of the algorithm, see here
and here
added on the 2008-11-17 18:04:12 by xyz xyz
Yep, I know I've got the source. Was looking for the details of the algo. Thanks! =D
added on the 2008-11-17 18:24:20 by b0ib0t b0ib0t
hehe :) and now back to the actual topic -- how to write a kewl oldskool lotus-2 type racing game for an oldskool platform..°!
added on the 2008-11-17 23:44:40 by xyz xyz

login