Dark Bit Factory & Gravity
PROGRAMMING => General coding questions => Topic started by: Pot Noodle on April 10, 2012
-
Hi guys, I have been writing an old Amiga Arcade Style game.
But having got purspective right i am stuck with getting corners/bends, i think it's a case of offseting the scanlines
but i just can't sort it out, i have tryed to use an array for the X cords but this produces funny effects, any ideas guys
so i may carry on with it.
Thanks.
;-----------------------------------------------------------------
; Old Amiga Arcade Style Game.
;-----------------------------------------------------------------
If InitSprite()=0 Or InitKeyboard()=0 Or InitSound()=0
MessageRequester("Error","Initializing Error!",0):End
EndIf
#ScrX=800:#ScrY=600:#ScrD=32
#ScanLines=200:#WidthStep=1
#LineWidth=1:#TotalLines=599
Global Dim ZMap.l(#ScanLines)
Global ScrollSpeed=10
For B=1 To #ScanLines
ZMap(B)=B*10
Next
If OpenScreen(#ScrX,#ScrY,#ScrD,"")
SetFrameRate(60)
; background=CatchImage(#PB_Any,?back)
Offset=100
X=400
Repeat
FlipBuffers()
ClearScreen(0)
StartDrawing(ScreenOutput())
; DrawImage(ImageID(background),0,0,830,336)
ScreenLine=#TotalLines
Distance=(290)
A.f=1
While A<#ScanLines
If Mod(ZMap(Int(A))+Offset,150)>50
GrasColor=$058303
RoadColor=$3b3b3b
LineColor=$3b3b3b
SideColor=$000099
Else
GrasColor=$057204
RoadColor=$3a3a3a
LineColor=$838582
SideColor=$aaaaaa
EndIf
LineXY(X-Distance,ScreenLine,X+Distance,ScreenLine,RoadColor) ; road
LineXY(0,ScreenLine,#ScrX-X-Distance,ScreenLine,GrasColor) ; left grass
LineXY(X+Distance,ScreenLine,#ScrX,ScreenLine,GrasColor) ; right grass
; centre lines
LineXY(X+(#LineWidth-Distance*0.02),ScreenLine,X+(#LineWidth+Distance*0.02),ScreenLine,LineColor)
; red+white side lines
LineXY(X-Distance,ScreenLine,X-Distance+5.0,ScreenLine,SideColor)
LineXY(X+Distance-5.0,ScreenLine,X+Distance,ScreenLine,SideColor)
ScreenLine-1 ; decreas line/y by 1
Distance-#WidthStep ; decreas the distance one line at a time
A+A*0.02
Wend
StopDrawing()
Offset+ScrollSpeed
If Offset>=150
Offset-150
EndIf
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
EndIf
; FreeImage(background)
End
DataSection
; back:IncludeBinary "back.bmp"
EndDataSection
-
@Pot Noodle, I'm a bit lost trying to figure out what you're trying to do. I take it you're making some sort of racing game. Is it a 3d thing? Do you have any screengrabs or sketches to illustrate what's happening or what you're trying to do?
-
Hi Raizor, I am trying my hand at re making the old Amiga game Jaguar XJ220, i have the scrolling road etc.. but i
just can't work out how to get the road to turn left & right, i know how it should work but everything i have tried has failed, here is a pic of what i have so far.
(http://dl.dropbox.com/u/71849177/Image.gif)
-
Ah, cool. I remember that game. Lotus 3 was my favourite back then :)
I think you're probably on the right lines (pardon the pun) with offsetting the vertical scanlines on the X plane. You'll need to do a bit more make it look right though, maybe scaling the scanlines as well as offsetting them to get a nice curve effect.
If you look at this picture, you can see what I mean on the top image with the green border.
The one with the red border isn't curving the track, just offsetting it.
-
Ya that's right Raizor, problem is where to start i think i may have to start over and rewrite the code
i just can't see a way forward with this one.
Thanks for the input mate.
-
Probably no need to start again, just modify what you have.
From looking at the images, I'd try just shaping the top half of the track on screen (the top 50% vertically) as that would likely give a good enough illusion of the corners turning.
If you want to upload the project (or post a link to it), I'll have a go at coming up with something. I'm quite intrigued as to how it would work anyway :)
Don't give up, looks like you're almost there...
-
Thanks Raizor, have a play with it and see what you think.
-
Thanks Pot Noodle. In the meantime, here are some things I found that might help:
Storing track data (racing track) (http://forum.gpwiki.org/viewtopic.php?t=9217)
Create a Racing Game Without a 3D Engine (http://active.tutsplus.com/tutorials/games/create-a-racing-game-without-a-3d-engine/) <- this looks to be right on the money!
Lou's Pseudo 3d Page v0.91 (http://www.gorenfeld.net/lou/pseudo/) Similar to above, looks very useful.
-
This is a routine that I had always meant to try writing but I've never got around to it, I was hoping to take a different approach though as in the old arcade game Powerdrift.
[youtube]Oc85td77ABw[/youtube]
Which uses sprite scaling and speed to achieve the illusion of track movement which is a total departure from the smooth routines in Jaguar XJ220 and the Lotus games which you're working on.
There must be dozens of different ways to make the effect, your screen shot looks promising..
Ya that's right Raizor, problem is where to start i think i may have to start over and rewrite the code
i just can't see a way forward with this one.
Don't give up :) I'll love to see what methods you use to do the curves and hills.. I always thought of breaking the track up into sections and placing my scaled sprites kind of like vectorbobs and dealing with the game logic like a 2D top down racer but interpreting the 2D map into the pseudo-3D display... The other way is like in Raizor's first link in the post above where the sections are just stored as a sequential list and each section has it's own characteristics that affects the car differently, with this approach it means you can throw the whole 3D side away and spoof it all.
I know this probably hasn't helped you much but I just wanted to post because I think it's a really cool project, good luck!
-
Ya, create a racing game without a 3D engine is so like my code already, uncanny :inspired: thanks Raizor
Shockwave you surprise me, i didn't think it would be your cup of tea, thanks for the info.
-
No worries Pot Noodle :)
I'll hang off from looking at the code until you've had another go at it. With those resources you should be able to get it working nicely. Keep us posted as to progress, I'm looking forward to playing it.
-
Shockwave you surprise me, i didn't think it would be your cup of tea, thanks for the info.
Well, the things that interested me most in the demos and cracktros on the Amiga were the effects that seemingly made the machine do something impossible, even from simple techniques like unlimited bobs to 1 Pixel RGB plasma, to things like Gods Cracktro By Ted / Defjam (http://www.retro-remakes.net/viewproduction.php?prod=af468b018d314a1a351a46848cc9dde41e319549)
I love techniques where you can cheat to get a seemingly impossible effect out of a limited machine - the road scrolling routine in XJ220 would come into that category :)
Also I spent a long time playing Lotus Esprit Turbo Challenge too :)
Besides, I've written a few games in my time too you know ;)
-
I still wish to make a cool game based on your rollertube demo one day! :)
-
Raizor would take a look at the math's of this for me as i am sure that it's not right, if you look at the red/white side lines they start big and then get smaller it should be the other way round but i just can't get it, Thanks.
-
Pot Noodle, take a look where?
-
Raizor at the code i gave you, if you run it you will notice the red & white lines are the wrong way around as they start big and get smaller.
-
Raizor at the code i gave you, if you run it you will notice the red & white lines are the wrong way around as they start big and get smaller.
Ah, :) Sorry, quite hungover today.
Hmmm... I can't get your code to run.
Line 27 causes a crash for me: StartDrawing(ScreenOutput())
[ERROR] The specified output is NULL (0 value).
Seems like ScreenOutput() returns NULL on consecutive calls. I wonder if this is an OS issue? I'm using Win7 x64 with the x86 version of PB (v4.51). I tried v4.60 too and get the same result. Any ideas?
-
That's strange, try changing the depth from 32 to 16 and see if that works
I don't think it's a win7 problem, i am using xp pro and PB ver 4.51
Thanks.
-
Will give that a try Pot Noodle thanks.
I did some googling yesterday and couldn't find much info. Some people were saying it's an issue with the DirectX subsystem relating to screen resizing which causes loaded assets to be lost.
-
Sorry Raizor, i think we posted at the same time, change depth from 32 to 16 and see
Thanks
-
Sorry Raizor, i think we posted at the same time, change depth from 32 to 16 and see
Thanks
Yep, that's sorted it, thanks. Will take a look at the code later today and try and figure out the lines issue.
-
Pot Noodle,
I've attached a RAR file with an updated version of the source.
I changed it to run in a window as it was taking about 20 seconds to start and stop the program each time. If this wasn't a problem for you or you don't like it, just paste the code from my version into yours.
To be honest, you almost had it sussed. I've basically done something very similar to what you where doing to scale the center grey lines - for the dashed lines at the left and right:
; middle grey lines
LineXY(CurrentX+(#LineWidth-Distance*0.04),ScreenLine,CurrentX+(#LineWidth+Distance*0.04),ScreenLine,LineColor)
; left dashed lines
LineXY(CurrentX-Distance-((#LineWidth-Distance*0.16)), ScreenLine, CurrentX-Distance, ScreenLine,SideColor)
; right dashed lines
LineXY(CurrentX+Distance,ScreenLine,CurrentX+Distance+((#LineWidth-Distance*0.16)),ScreenLine,SideColor)
For the left lines, we offset the start position of the line by an amount calculated using your Distance variable which lets us know how far down the screen (Y pos) we are. We do the same for the right side too, but offset the end position of the line instead of the start position.
You can change the thickness/scale of the lines by changing the 0.16 values above.
As you progress with this, you might want to work out those offsets in advance as you're performing the same multiplications a few times at present. It probably doesn't matter too much, but if you add more code and it starts to slow down, give it some thought. As your screen height stays the same, you could also pre-calculate a table or two with the various values and use that as a lookup table to get the best performance.
Once again, I learned a bit more about Pure Basic while doing this, so all good :)
Hope it helps and does what you want.
Cheers,
Joe
EDIT: Would help it I attached the file :P
-
Also, this is worth a look (http://glsl.heroku.com/e#1329.0). Not sure how useful the code will be to you, but you might be able to deduce some tricks.
-
Brill thanks Raizor :clap: I had thought of a window insted of full screen but was to busy trying to sort the lines out.
Now i can consentrate on the bends ::)
Thanks again for all your help.
-
No worries Pot Noodle. Looking forward to seeing the bends :)
-
Raizor check out the curves and see if think it's OK may want tweaking..
-
Looking good :D
Only comment is that as the curves flips from one side to the other the movement starts off soft and then gets very hard toward the end of the transition. This might just be your test movement, but it looks a bit weird imho. Very cool curves though.
-
Does anyone have any idea why the curves are so jumpy, i have tried everything i can think off
god this is a real pain, something to do with the ddx value but i can't sort it out.
:'(
-
Are A, DX, DDX etc your own variable names? If so, you should probably give them names that reflect what they're used for. DistanceX and DistanceXIncrement or something like that. It helps make the code much easier to follow :)
-
Yes i know what you are saying the variable A is just a loop counter and as for DDX it holds a float value for shifting the lines X values & DX is used to increment DDX so it looks like this DX + DDX, this i think is where the problem is but i have changed it but to no avail. :(
-
Hey Raizor, Just to keep you up to date, the programme is looking good now I have had help from else where
But all is good and Thanks again for all your time and help, you were bang on with your ideas. :clap:
-
Great that you got it sorted Pot Noodle :)
Post another preview when you get time please, I'd be interested to see it.