UnderwareDESIGN

PlayBASIC => 3D Development => Topic started by: kevin on February 04, 2006, 12:20:22 PM

Title: 2D game viewed with 3D Camera
Post by: kevin on February 04, 2006, 12:20:22 PM
2D Platformer in 3D World Tech Demo + Source Code


  This example (techdemo) is viewing the map from the 2D plat former example using a first person camera (ie via rotating a vertex list to the camera).   The example is written in PB v1.27  as a testing ground for future camera enhancements.

  This version includes source code,  it's a bit bloated now as various functions have become redundant due to the new TranslateMeshToScene command, but you get that. :)

Download

[plink] Download Demo + Src  (http://www.underwaredesign.com/files/pub/PlayBasic/Examples/UW/2D_Platformer_In_3DWorld_V004.zip)[/plink] (1.3 meg ish)


  Free LearnToCode


Video




Title: 2D game viewed with 3D Camera
Post by: Draco9898 on February 04, 2006, 08:06:39 PM
Woah, very cool
Title: 2D game viewed with 3D Camera
Post by: Digital Awakening on February 05, 2006, 05:34:14 AM
Yeah, that's looking cool.
Title: 2D game viewed with 3D Camera
Post by: kevin on February 05, 2006, 02:49:14 PM
In this update  the player can run around within the 2d map within the 3D world.   There's two modes   1) a sort of attach to player and  2) is a FPS mode.

 Performance wise on my good old Duron 800 it's not express (20fps), but  considering this demo has no polygon clipping and is written in PB and not a part of the engine.  I'm actually staggered it's even capable of moving let alone being playable.  

 The clipping is a major issue. Currently it just turns every tile into a polygon and attempts a brute force render of every tile.   This is really not necessary.  As only the region of the map what is within the camera should be considered.    Which removes truck load of overhead.  but a good exercse for the time being

 But anyway.. Also,  the Running animation is by BlinkOK,  which i've  seriously butchered when resizing it .. :)
Title: 2D game viewed with 3D Camera
Post by: Calypson on February 05, 2006, 03:49:45 PM
hey i recognise those tiles  :D  I think a VERY cool person made them... hmm.. i wonder who that could be.
Title: 2D game viewed with 3D Camera
Post by: Fash on February 05, 2006, 03:59:29 PM
QuoteI think a VERY cool person made them
Nice gfx Calypson :)

Look forward to seeing that in action Kevin...
Title: 2D game viewed with 3D Camera
Post by: kevin on February 06, 2006, 03:48:01 PM
Yeah the image format on the grabbed animation isn't correct.  Cut an paste the above 3 lines in the MAIN source.
Title: 2D game viewed with 3D Camera
Post by: thaaks on February 06, 2006, 03:57:11 PM
That's really impressive, Kevin!

And all this zooming in and out - I see a lot of "drunken camera" games ahead  :D

Only worked with Beta 1.13 - the 1.11 didn't have the ScreenModeExist() function...

Cheers,
Tommy
Title: 2D game viewed with 3D Camera
Post by: kevin on February 06, 2006, 04:23:35 PM
lol - Now there's an idea. A sea sick simulation !   Coming soon "The vomit commit"

 I prolly should mention that, you can also create a ground effect like in those 'wacky wheel's style games using the same approach. Just simply rotated the map plane around the X axis.   Although at the moment there's no near and far zclipping.  So negative polygons will just vanish.
Title: 2D game viewed with 3D Camera
Post by: Draco9898 on February 06, 2006, 05:41:50 PM
Anyway you could make this a native command in the language?

This looks like a great way to make those 2d/3d 'flat' world maps I've always been trying to emulate. A.K.A MarioKart on SNES...
Title: 2D game viewed with 3D Camera
Post by: Calypson on February 06, 2006, 09:28:05 PM
simply amazing... great concept for a game - although i can't quite think of how it'd work... either way - it sure does make my map look way more depthy
Title: 2D game viewed with 3D Camera
Post by: kevin on February 07, 2006, 05:55:20 AM
QuoteAnyway you could make this a native command in the language?

 From the first post-  The example is written in PB v1.11 as a testing ground for future camera enhancements.

 Meaning yes, 3D camera support will be native to PB, since it's required for PBFX.    It'll be a little more complex than just a command though.  Camera's need at least 2 modes, these will effect how items are viewed.  The same applies to the captured items as well.  The user will need a way to control how or if perspective/rotation effect them  

 Another  difference is the Y axis in 2D and 3D, point in opposite directions.   Which will no doubt be confusing at first.  

QuoteThis looks like a great way to make those 2d/3d 'flat' world maps I've always been trying to emulate. A.K.A MarioKart on SNES...

 There's nothing new about it, it's a textured vertex plane. That's about it. I'm surprised somebody hasn't already done it.
Title: 2D game viewed with 3D Camera
Post by: Digital Awakening on February 07, 2006, 12:09:02 PM
Various SNES animations passes before my eyes :)
Title: 2D game viewed with 3D Camera
Post by: kevin on March 01, 2006, 08:50:43 AM
Update

   I've been updating this demo today, since I had always intended it to be a Tech demo, but I just don't have any decent animations.   But  BlinkOK has been kind enough to not only create a ultra new smooth running animation, but grant permission to use some of his characters animation  in the tech also.

  Apart from adding the animations I've been quietly implementing a TranslateMeshToCamera function.  This function takes the rotated vertices and pushes a prebuilt mesh of polygons into the scene buffer.   Lifting the bulk the work off the VM's shoulders.   Which result in it running around 30 fps in 640*480*32bit on my Duron 800mhz / GF2 machine.   And only fractionally slower in 800*600*32bit  (25fps)

 While at the moment the rotation and mesh translation are fairly hands on, they do give you a much greater canvass to bring your creations to life.

  I was going to post the new demo, but i'ts got a few bugs in it.  So you'll just have to put up with an updated screen shot.
Title: 2D game viewed with 3D Camera
Post by: Draco9898 on March 01, 2006, 09:04:07 AM
Well, techniquely, that's my kinght guy design in Blink's animation, but whatever :)

cool beans...
Title: 2D game viewed with 3D Camera
Post by: Ian Price on March 01, 2006, 09:34:37 AM
Sounds as though this is coming on in leaps and bounds  :)
Title: 2D game viewed with 3D Camera
Post by: kevin on March 10, 2006, 08:42:06 AM
Another Demo With Source Code requires testing !

  Here's the updated version of the 2d Platformer in 3D scene demo.  This version include an exe and the source code. The code requires PB1.23 (i'll upload that later on tonight)  The main difference is that this version used the newly incorporated TranslateMeshToScene. Which can take a static mesh and a set of rotated vertex and translate them directly into the scene buffer.  Thus removing the main brute force operation from the original demo.

Note:  I've released this version early as I need your help verifying the crash problem has been eliminated.  Previously in roam mode you could get the odd lock up when flying around.   I believe this was now caused by from rouge division that hit infinity within the projection code. While i'm pretty sure, i'm not 100% sure. (although it hasn't crashed here since i fixed that)   So just in case, this version only runs in windowed mode.  




Download

 Old Download Removed
Title: 2D game viewed with 3D Camera
Post by: kevin on March 10, 2006, 08:49:40 AM
picture
Title: 2D game viewed with 3D Camera
Post by: Ian Price on March 10, 2006, 09:00:38 AM
Very nice :D

Even on 1024x768 32 Bit resolution I'm getting over 75 FPS (typically 80+) - too fast to play!

No crashes despite throwing it around a fair old bit.
Title: 2D game viewed with 3D Camera
Post by: kevin on March 10, 2006, 09:33:53 AM
That's pretty nice rate in windowed mode at that res !

I'm glad you've not been able to kill it either, so i think this issue has been fixed.
Title: 2D game viewed with 3D Camera
Post by: kevin on March 16, 2006, 03:04:37 PM
2D Platformer in 3D World Tech Demo with Source Code

  Since the previous version was stable, here's the final update of this tech demo. I've added a few tidbits on open/close, but the core demo is the same really.

 This version includes source code,  it's a bit bloated now as there's various functions that have become redundant due to the TranslateMeshToScene command, but you get that.


Download
[plink] Download Demo + Src  (http://www.underwaredesign.com/files/pub/PlayBasic/Examples/UW/2D_Platformer_In_3DWorld_V004.zip)[/plink] (1.3 meg ish)

Title: 2D game viewed with 3D Camera
Post by: medwayman on March 27, 2006, 03:38:33 PM
Very impressive and very cool. :D

Live the new logo btw :)
Title: 2D game viewed with 3D Camera
Post by: Calypson on March 28, 2006, 02:29:12 PM
yes - i must agree that the new logo rocks.

also, with my new compy, I get 60 FPS at 1024 by 768, 32bit.

too fast to play the game actually - i'll hafta put a FPS cap on it
Title: 2D game viewed with 3D Camera
Post by: kevin on March 28, 2006, 03:32:42 PM
Yeah, Kohai's version of the PB logo is really growing on me.  The newest version has slightly different colours than that one. More blue than greeny
Title: 2D game viewed with 3D Camera
Post by: Fash on April 05, 2006, 04:38:08 PM
When compiling the source under the latest pb (+beta ide) I get a 288 fatal error - bank #0 out of legal range

compiler 1.28c
ide 1.1.0
(the exe runs fine though, albeit a tad fast, LOL)

Steve

PS The new logo looks fantastic :)
Title: 2D game viewed with 3D Camera
Post by: kevin on April 05, 2006, 06:42:47 PM
There's a line of code that's not used.  It were it'd die with a fatal exception :)

Open the project, go to MAIN and find line 286.   It's just inside the demos main DO/LOOP

 which looks like this

[pbcode]
Do
   RenderToScreen
;  BackDrop()

   CaptureToScene
   ClsScene

; Rotate vertex list (with XYZ rotation order)
    CameraAddress=GetBankPtr(CameraObject)
;     ObjectAddress=GetBankPtr(VertexObject)  <<< remove this one line

[/pbcode]
Title: 2D game viewed with 3D Camera
Post by: Fash on April 06, 2006, 12:53:34 AM
Perfect :)
Thanks Kevin.

Steve