Author Topic: Turning Corners  (Read 12799 times)

0 Members and 1 Guest are viewing this topic.

Offline Pot Noodle

  • Sponsor
  • Amiga 1200
  • *******
  • Posts: 271
  • Karma: 15
  • Computers have lots of memory but no imagination
    • View Profile
Turning Corners
« 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
 

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Turning Corners
« Reply #1 on: April 11, 2012 »
@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?
raizor

Challenge Trophies Won:

Offline Pot Noodle

  • Sponsor
  • Amiga 1200
  • *******
  • Posts: 271
  • Karma: 15
  • Computers have lots of memory but no imagination
    • View Profile
Re: Turning Corners
« Reply #2 on: April 11, 2012 »
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.


Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Turning Corners
« Reply #3 on: April 11, 2012 »
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.
raizor

Challenge Trophies Won:

Offline Pot Noodle

  • Sponsor
  • Amiga 1200
  • *******
  • Posts: 271
  • Karma: 15
  • Computers have lots of memory but no imagination
    • View Profile
Re: Turning Corners
« Reply #4 on: April 11, 2012 »
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.

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Turning Corners
« Reply #5 on: April 11, 2012 »
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...
raizor

Challenge Trophies Won:

Offline Pot Noodle

  • Sponsor
  • Amiga 1200
  • *******
  • Posts: 271
  • Karma: 15
  • Computers have lots of memory but no imagination
    • View Profile
Re: Turning Corners
« Reply #6 on: April 11, 2012 »
Thanks Raizor, have a play with it and see what you think.

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Turning Corners
« Reply #7 on: April 12, 2012 »
Thanks Pot Noodle. In the meantime, here are some things I found that might help:

Storing track data (racing track)

Create a Racing Game Without a 3D Engine <- this looks to be right on the money!

Lou's Pseudo 3d Page v0.91 Similar to above, looks very useful.

raizor

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Turning Corners
« Reply #8 on: April 13, 2012 »
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..

Quote
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!
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Pot Noodle

  • Sponsor
  • Amiga 1200
  • *******
  • Posts: 271
  • Karma: 15
  • Computers have lots of memory but no imagination
    • View Profile
Re: Turning Corners
« Reply #9 on: April 13, 2012 »
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.

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Turning Corners
« Reply #10 on: April 13, 2012 »
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.
raizor

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Turning Corners
« Reply #11 on: April 14, 2012 »
Quote
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

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  ;)

Shockwave ^ Codigos
Challenge Trophies Won:

Offline Kirl

  • Senior Member
  • Pentium
  • ********
  • Posts: 1217
  • Karma: 230
    • View Profile
    • Homepage
Re: Turning Corners
« Reply #12 on: April 14, 2012 »
I still wish to make a cool game based on your rollertube demo one day! :)

www.kirl.nl
Challenge Trophies Won:

Offline Pot Noodle

  • Sponsor
  • Amiga 1200
  • *******
  • Posts: 271
  • Karma: 15
  • Computers have lots of memory but no imagination
    • View Profile
Re: Turning Corners
« Reply #13 on: April 15, 2012 »
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.

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Turning Corners
« Reply #14 on: April 15, 2012 »
Pot Noodle, take a look where?
raizor

Challenge Trophies Won:

Offline Pot Noodle

  • Sponsor
  • Amiga 1200
  • *******
  • Posts: 271
  • Karma: 15
  • Computers have lots of memory but no imagination
    • View Profile
Re: Turning Corners
« Reply #15 on: April 15, 2012 »
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.

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Turning Corners
« Reply #16 on: April 15, 2012 »
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?
« Last Edit: April 15, 2012 by Raizor »
raizor

Challenge Trophies Won:

Offline Pot Noodle

  • Sponsor
  • Amiga 1200
  • *******
  • Posts: 271
  • Karma: 15
  • Computers have lots of memory but no imagination
    • View Profile
Re: Turning Corners
« Reply #17 on: April 16, 2012 »
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.
« Last Edit: April 16, 2012 by Pot Noodle »

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Turning Corners
« Reply #18 on: April 16, 2012 »
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.
raizor

Challenge Trophies Won:

Offline Pot Noodle

  • Sponsor
  • Amiga 1200
  • *******
  • Posts: 271
  • Karma: 15
  • Computers have lots of memory but no imagination
    • View Profile
Re: Turning Corners
« Reply #19 on: April 16, 2012 »
Sorry Raizor, i think we posted at the same time, change depth from 32 to 16 and see
Thanks