PDA

View Full Version : Mario Kart - Mode 7 Graphics



wagenheimer
29-08-2011, 10:17 PM
Hi guys!

I have seen a nice example of a Mario Kart like game using Monkey, and I'm trying to port it to Pascal using the ZenGL game Engine.

Well... here is the original result!

http://www.monkeycoder.co.nz/Apps/screenshots/83-1.jpg

You can test this demo (http://www.monkeycoder.co.nz/Community/topics.php?forum=1083&app_id=83) and download it's monkey source code here (http://earok.net/game/earoks-monkey-demos)

But, here is my ZenGL Version!
http://www.wagenheimer.com/temp/MarioKartZenGL.jpg
For sure, something is wrong with my version! :P

Attached there is the demo and the binaries of my version.

I think something is wrong with my DrawMode7 function (And I really don't understand how it works, and I would love to understand it!). =P

Original Code (Monkey Code) :


DrawImage ImgSky,0,0

For Local a = 0 to YLines-1

'Detect the X and Y location in the 3D world where the ray hit
Local XHit:Float = CameraX + (cosine*VDist[a])
Local YHit:Float = CameraY + (sine*VDist[a])

'Draw only this single line
SetScissor(0,240+a,XRes,1)

'Position, scale and rotate the image to draw on screen
ImgTrack.SetHandle(XHit,YHit)
DrawImage ImgTrack,320,240+a,-(CameraDir-90),VScale[a],VScale[a]
Next

SetScissor(0,0,XRes,YRes)


Well... To help :
Method SetHandle( x#, y# ) - Sets the image offset handle for this image. The handle is a 2D offset subtracted from the x,y coordinates of the image when it is drawn.
Function DrawImage( image:Image, x#, y#, rotation#, scaleX#, scaleY#, frame=0 )

My Code :


asprite2d_Draw(texBack, 0, 0, texBack.Width, texBack.Height, 0, 1);

For a := 0 to YLines - 1 do
begin
// Detect the X and Y location in the 3D world where the ray hit
XHit := CameraX + (cosine * VDist[a]);
YHit := CameraY + (sine * VDist[a]);

// Draw only this single line
scissor_Begin(0, 240 + a, XRes, 1);

// 'Position, scale and rotate the image to draw on screen
fx2d_SetRotatingPivot(XHit, YHit);
fx2d_SetScale(VScale[a], VScale[a]);
asprite2d_Draw(texTrack, 320, 240 + a, texTrack.Width, texTrack.Height, -(CameraDir - 90), 1, 255, FX_BLEND or FX2D_RPIVOT or FX2D_SCALE);
scissor_End;
end;


Some of you guys have any idea of what I'm doing wrong and how can I fix it?

Thanks!

Andru
30-08-2011, 06:50 AM
I think this is because of difference in how Monkey and ZenGL render sprites with Scale and Rotating Pivot. So, your code is right(except procedure Update without parameter dt : Double, which cause an Exception when exit the demo :)), only ZenGL need a changes. But demo is interesting, so as soon as I get free time, I will try to figure out how it should works... :)

Andru
30-08-2011, 06:17 PM
I have investigated this, and found that SetHandle in Monkey works something like ZenGL camera, but not like fx2d_SetRotatingPivot.