Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Dungeoneer - publicly available android sample!
Started by rakoonic2 Oct 09 2013 03:19 AM

20 replies to this topic
graphics 2 dungeoneer
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

rakoonic2

[GLOBAL: userInfoPane.html]
rakoonic2
  • Contributor

  • 503 posts
  • Corona SDK

https://www.dropbox.com/s/9o3z8nijgo42mw2/Dungeoneer.apk

 

I've only just now tested on my phone, so yeah I know buttons are a bit small if you are going to run on a small device.

Some warnings:

 

1) It has a corona memory leak, so it will slow down and crash eventually (faster the more players you have)

2) I was in the middle of working on inventories when I published this, so in 2 or more players, chances are that the movement buttons may be obscured

3) Fullscreen content scaling hasn't been implemented yet, so you might well get a border either on the right or bottom of the screen, depending on your aspect ratio.



[TOPIC: post.html]
#2

Alex@Panc

[GLOBAL: userInfoPane.html]
Alex@Panc
  • Corona Geek

  • 1,731 posts
  • Corona SDK

Pretty fantastic, I must say. Thanks for sharing!



[TOPIC: post.html]
#3

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,476 posts
  • Enterprise

Pretty cool.



[TOPIC: post.html]
#4

Matthew Pringle

[GLOBAL: userInfoPane.html]
Matthew Pringle
  • Contributor

  • 660 posts
  • Corona SDK

Can you share some sample code?



[TOPIC: post.html]
#5

rakoonic2

[GLOBAL: userInfoPane.html]
rakoonic2
  • Contributor

  • 503 posts
  • Corona SDK

I am indeed planning something in the near future, although it is likely to be a more general 3d thing than dungeoneer.

[TOPIC: post.html]
#6

Matthew Pringle

[GLOBAL: userInfoPane.html]
Matthew Pringle
  • Contributor

  • 660 posts
  • Corona SDK

Any chance you can dump a bit of code in here to show how you are setting up the floor.

 

Are you just calculating the 4 corner points of each plane projected and then manipulating the anchors of each plane to fit on a 2d screen?



[TOPIC: post.html]
#7

rakoonic2

[GLOBAL: userInfoPane.html]
rakoonic2
  • Contributor

  • 503 posts
  • Corona SDK

Yeah that is all I'm doing.

The only point worth knowing as it is unintuitive is that the path property of an image is a series of offsets from the corners of the image - so if you calculate the corner points you can't just place these values directly into the path.

The path starts top left and goes counter-clockwise, so you'd need to do (psuedo code):

 

path.x1 = a.x
path.y1 = a.y

path.x2 = b.x
path.y2 = b.y - imageHeight

path.x3 = c.x - imageWidth
path.y3 = c.y - imageHeight

path.x4 = d.x - imageWidth
path.y4 = d.y

 
where a, b, c and d are the corners converted to screen coordinates.

 



[TOPIC: post.html]
#8

Matthew Pringle

[GLOBAL: userInfoPane.html]
Matthew Pringle
  • Contributor

  • 660 posts
  • Corona SDK

How are you finding the processing hit per frame?

 

I think I read somewhere you said you could maintain 8 tiles and not take a hit to fps?

 

Was that in realtime, could it animate?

 

Thanks BTW



[TOPIC: post.html]
#9

rakoonic2

[GLOBAL: userInfoPane.html]
rakoonic2
  • Contributor

  • 503 posts
  • Corona SDK

Ah no, that was me early on saying I managed 8 fps in my game on an ipad 2 - but that is drawing errrr dunno, around 150 'polygons' (IE distorted images) per frame. I've got that now up to around 60fps, although it is borderline - on more complicated views it drops to 30 fps, so finding the sweet spot would be tricky if I were aiming for 60 fps (but I'm not, I'll likely set the config framerate to 30, and the engine itself will only update at 15 or maybe even less).

 

Can you have realtime 3D? yes - the racing game demo easily runs at 60 fps including the fullscreen motion blur (although you naturally just keep adding more and more objects until it doesn't).

 

I did a brief test earlier with super-hacked smooth movement and yes, it is fine (as in, there's no speed hit for tweening between cells in my game, as opposed to moving cell by cell), because it is just drawing the same view with a few values. What I can't do is rotate, although that's a limitation due to the nature of the game, not anything inherent in graphics 2 (and if I have time soon I'll try to sort out a mode 7 demo).



[TOPIC: post.html]
#10

Matthew Pringle

[GLOBAL: userInfoPane.html]
Matthew Pringle
  • Contributor

  • 660 posts
  • Corona SDK

moved down



[TOPIC: post.html]
#11

Matthew Pringle

[GLOBAL: userInfoPane.html]
Matthew Pringle
  • Contributor

  • 660 posts
  • Corona SDK

I was thinking about doing a mode 7 style engine, at least a test.

 

There is obviously the distorting image way of doing it, which I am working on at the mo.

 

But there is also the possibility of using 1px high snapshots to act as scanlines and doing it the real way, of moving, scaling and rotating the image many times over.

 

I think it would need to be rendered small, say at 240 x 160 and then scaled to fit the screen afterwards. Need to look at how much a performance hit doing 160 snapshots is.

 

Maybe even smaller. I achieved something similar a while ago on graphics 1 http://developer.coronalabs.com/code/3d-tunnel



[TOPIC: post.html]
#12

rakoonic2

[GLOBAL: userInfoPane.html]
rakoonic2
  • Contributor

  • 503 posts
  • Corona SDK

You don't need to do that. Or at least not scanline by scanline.

What my plan was is to render the tilemap top down into a snapshot, and distort the snapshot in perspective to get the end result (although you might well want to split it into various snapshots to avoid having to render too much that wouldn't be shown).

 

I haven't tested it myself, but you should be able to distort snapshots like any other image - certainly I've manipulated them in other ways along similar lines.

 

 

One thing that is useful is that I use snapshots in the racey game as a cheap pixelate filter - I render to a snapshot (say) that is 1/4 of the screen in size, zoom it, and ta-dah! Pixelated! But the true upside is you naturally render all your game elements smaller, so it actually works out quicker to boot. I was rather pleased when I found that out ;)



[TOPIC: post.html]
#13

rakoonic2

[GLOBAL: userInfoPane.html]
rakoonic2
  • Contributor

  • 503 posts
  • Corona SDK

Ah did you also do the wolfenstein demo I recall seeing in the code share place?

I did a pre-graphics 2 demo ages ago of the racing game where instead of distorting each track section I just used slivers. I did actually manage to get it up to 60 fps with heavy pixelating, but it was really only a test to try to push my case for quads, which we now have in G2.



[TOPIC: post.html]
#14

Matthew Pringle

[GLOBAL: userInfoPane.html]
Matthew Pringle
  • Contributor

  • 660 posts
  • Corona SDK

Nope, but I will have to have a look for that!



[TOPIC: post.html]
#15

rakoonic2

[GLOBAL: userInfoPane.html]
rakoonic2
  • Contributor

  • 503 posts
  • Corona SDK

I think it was more a test-case for raycasting than for rendering, but it worked well enough.



[TOPIC: post.html]
#16

Matthew Pringle

[GLOBAL: userInfoPane.html]
Matthew Pringle
  • Contributor

  • 660 posts
  • Corona SDK

I did this ray casting demo which scanned a tile map and computed shadows.

 

http://forums.coronalabs.com/topic/6453-field-of-view-shadow-casting-demo/



[TOPIC: post.html]
#17

rakoonic2

[GLOBAL: userInfoPane.html]
rakoonic2
  • Contributor

  • 503 posts
  • Corona SDK

Ah that is great stuff. That thread includes a few nice bits.

Dungeoneer actually uses raycasting for culling, although I got lazy and did it in screencoordinates - plus I made a ton of shortcuts because the view is always axes-aligned.

 

Wolfenstein would be very doable now - in fact it'd likely be quicker to just draw everything as the scenery was hardly complicated.

The main issue with any real 3D is there's no culling at the Z = 0 plane (in dungeoneer I solve this by just moving the view point back 1 cell so everything is always 'in front', but you'd not be able to do that directly with something like wolfenstein, as you'd very quickly notice the odd rotation).



[TOPIC: post.html]
#18

rakoonic2

[GLOBAL: userInfoPane.html]
rakoonic2
  • Contributor

  • 503 posts
  • Corona SDK

Now you've made me want to write a doom-style game. I used to do a lot of doom stuff, and wrote my own WAD importer / viewer. Given my playing with dungeoneer, it would soooorta be possible to do, but I shudder to think at the hacks needed!



[TOPIC: post.html]
#19

Matthew Pringle

[GLOBAL: userInfoPane.html]
Matthew Pringle
  • Contributor

  • 660 posts
  • Corona SDK

Sooner or later someone probably will.



[TOPIC: post.html]
#20

rakoonic2

[GLOBAL: userInfoPane.html]
rakoonic2
  • Contributor

  • 503 posts
  • Corona SDK

Not so sure. To do so would have to be a purely technical exercise, as when you start getting into more complex proper 3D, you'd be better off doing it in unity or something :)

 

BTW what is with the comments getting merged into the thread in odd positions? I have to leave it and come back in to see everything ordered properly...



[TOPIC: post.html]
#21

Matthew Pringle

[GLOBAL: userInfoPane.html]
Matthew Pringle
  • Contributor

  • 660 posts
  • Corona SDK

I noticed too, hence the previous comment "moved down".

 

Unity is cool, I was just starting to build something in that. Thought I might look back now as Corona has the new engine and it allows for some stuff I was developing for before but then hit technical walls.




[topic_controls]
 
[/topic_controls]