Jump to content




Wolf3d-style 3d engine (proof of concept)


56 replies to this topic

#1 GopherAtl

  • Members
  • 888 posts

Posted 28 February 2013 - 09:35 PM

new update: added optional support for my redirect api, which creates buffered redirect objects that can, among other things, be used to implement a back buffer. If the redirect api is found, it does all the messy drawing to a buffer, then copies that to the screen all at once. For me, this eliminated all flicker even on a max-size monitor at text scale .5. ymmv.


on a whim, decided to throw together a simple Wolfenstein 3D-style rendering system in cc. Two hours later, here are the results


Posted Image
Posted Image

screenshots look pretty crappy, what with the 51x19 resolution and 16-color palette, but to properly appreciate it you need to see it in action.
Demo download: pastebin get qpV90qbM wolf3d

I strongly recommended you also grab the redirect API, which will be used if you have it to reduce or eliminate any flickering when drawing. It'll still run fine without it, though. (for more info on the redirect api, see my api thread)

redirect api (optional): pastebin get fU9Kj9zr redirect

pastebin version will keep updating as I work on it. Feel free to take the code and turn it into anything you want.

#2 oeed

    Oversimplifier

  • Members
  • 2,095 posts
  • LocationAuckland, New Zealand

Posted 28 February 2013 - 10:10 PM

Wow.
Can't believe how small it is too, only 176 lines!

#3 BigSHinyToys

  • Members
  • 1,001 posts

Posted 28 February 2013 - 10:23 PM

Now make COD lolz

Great work this is really well done + 1

#4 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 28 February 2013 - 10:45 PM

Very nice! :D I wish we had a way to render more pixel detail. would make it look so much better. only real way i can think of is using ascii. but very nice none the less.

#5 GopherAtl

  • Members
  • 888 posts

Posted 28 February 2013 - 10:46 PM

oeed: thanks. Additions, mainly collision handling with walls, have pushed it to around 250 lines now, but yeah, this kind of engine is surprisingly simple to implement, heh.

BigSHinyToys: no COD, lol. Adding enemies would be ... problematic. 16-color sprites at this resolution really don't scale well!

TheOriginalBit: I've toyed with making it run on monitors, but it would have to have on-screen touch controls, ipad-style, which seems like it'll be awkward. Unless there's actually a working version of ccinput around somewhere, seems every time I've tried to use ccinput, it has not wanted to work properly...

#6 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 01 March 2013 - 04:47 AM

WOw, this is amazing xD

Try add multiplayer support :o

#7 nutcase84

  • Members
  • 711 posts
  • LocationIn My Lonely Little Computer Corner

Posted 01 March 2013 - 05:26 AM

OMG! GopherAlt, you are amazing! Make it a shooter and I will bow down to you!

#8 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 01 March 2013 - 05:34 AM

Lol got trapped at the dead end :P

#9 Rsstn

  • Members
  • 53 posts
  • LocationLondon, UK

Posted 01 March 2013 - 07:54 AM

Awesome, trying it out!

#10 Zaggy1024

  • Members
  • 23 posts

Posted 01 March 2013 - 08:02 AM

I just threw together a few little changes to this because I felt like it needed them. I made the frames be on a timer, which made it flash less (or maybe never), added mouse support for looking left and right (it isn't perfect, because of the way ComputerCraft does mouse_drag events, but it works pretty well), I made it scale properly (possibly not completely properly, but it seems to work), and I put a crosshair in the middle of the screen just for good measure.

http://pastebin.com/V5MRGVZv

#11 Exerro

  • Members
  • 800 posts

Posted 01 March 2013 - 11:10 AM

wow, i can't even make a 3d game with collision with lwjgl and you do it in cc! so jealous :P great job :D

#12 Derp_Herpsworth

  • Members
  • 7 posts

Posted 01 March 2013 - 11:34 AM

You, my friend, deserve a trophy. I'll be happy to try to discover how good it is. :D

#13 GopherAtl

  • Members
  • 888 posts

Posted 01 March 2013 - 12:00 PM

 Zaggy1024, on 01 March 2013 - 08:02 AM, said:

I just threw together a few little changes to this because I felt like it needed them. I made the frames be on a timer, which made it flash less (or maybe never), added mouse support for looking left and right (it isn't perfect, because of the way ComputerCraft does mouse_drag events, but it works pretty well), I made it scale properly (possibly not completely properly, but it seems to work), and I put a crosshair in the middle of the screen just for good measure.

http://pastebin.com/V5MRGVZv

I don't see how making it redraw every frame would help the flicker; I will be making it use my redirect buffer api later (not really sure why I didn't in the first place), which should significantly reduce, if not completely eliminate, the flickering. I'd also implemented automatic scaling to term.getSize() last night, but forgot to update pastebin. Regardless, tho, mod away, make what you want with it!


To everyone else, thanks for the praise, been a fun little diversion from my usual more complex and practical projects :)

#14 oeed

    Oversimplifier

  • Members
  • 2,095 posts
  • LocationAuckland, New Zealand

Posted 01 March 2013 - 12:04 PM

 GopherAtl, on 01 March 2013 - 12:00 PM, said:

--snip snip--

To everyone else, thanks for the praise, been a fun little diversion from my usual more complex and practical projects :)

How isn't this practical :P

#15 Left4Cake

  • Members
  • 272 posts
  • LocationEarth

Posted 02 March 2013 - 04:08 AM

This could be use as a 3d map for levels of a dungeon for house.

#16 wilcomega

  • Members
  • 466 posts
  • LocationHolland

Posted 02 March 2013 - 04:40 AM

this is sooooo amazing. i have been waiting for this. maybe nitrogenfingers will incude it in the gameutils api. i love it. when i implements that i will make a first person shooter! :D :D :D you are truely amaing. i cant tell you enough

#17 martin509

  • Members
  • 53 posts

Posted 02 March 2013 - 04:17 PM

I feel like another of the horde of Tekkit users saying this, but.. Can has standard PC version?
Also, maybe add some things like slash+dash lines on the outer edges of polygons, to give it texture.
Oh, and maybe take it a step further with walls of varying height.

#18 GopherAtl

  • Members
  • 888 posts

Posted 02 March 2013 - 07:05 PM

ehrum. Yeah, it would have to have some sort of characters as texturing to be remotely comprehensible visually in a version for basic computers. The current algorithm doesn't really lend itself to drawing the edges, so adding that would require some fairly significant rewriting. I may attempt something like that in the future, but not at this time I'm afraid.

#19 wilcomega

  • Members
  • 466 posts
  • LocationHolland

Posted 03 March 2013 - 12:12 AM

i have said this before: AMAZING
but i would like to see a diffrent map format. like map[x][y] = object5
or like map[x][y] = player2. i also would like to see some object oriented programming. like i did above. that you draw objects
on the screen according to their position. instead of a map. if you know what i mean.
so it will be easyer to make fps( first person shooters ). that is my plan atleast

you should make an explanation on how each line of code works and what it does. i really want to make smaller objects in the world. like bullets :P

#20 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,450 posts

Posted 03 March 2013 - 05:58 AM

This is a proof of concept. Try to be a little less entitled and demanding when other people make cool stuff.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users