Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
3D-ized 2D, a sort of challenge or a how to question...
#1
I was thinking and wondering how one might skew 2D Space Invaders to look 3D, like 
[Image: IMG-6833.png]

and also have photoreal stars scrolling in the background, like 
[Image: IMG-6834.jpg]

[Image: IMG-6835.jpg]

simularly skewed, playing in a loop. 
With the scene sometimes flying through space dust clouds, like 
[Image: IMG-6836.webp]

[Image: IMG-6837.jpg]

[Image: IMG-6838.gif]

Just something I imagined. 
The actual game play would similar to the classic game except the aliens might move in more interesting ways, like have the entire formation move around at times or have rows or columns of them move on & off screen, and let the player fire 2 or more shots. 

But mainly I'm curious how you would skew the 2D to look 3D and do the 3D scrolling and moving through clouds (which could at times obscure the view)... The game itself would be programmed and behave like a 2D game though. 



focus in you emojis
Reply
#2
Yeah, I played around with this idea some time back as well. I thought _MAPTRIANGLE would work for this, but nope, run the code to see the problem.

Code: (Select All)
DIM Image AS LONG
Image = _LOADIMAGE("si.png", 32)
SCREEN _NEWIMAGE(640, 480, 32)
_MAPTRIANGLE (0, 0)-(0, 479)-(639, 479), Image TO(100, 0)-(0, 479)-(639, 479), 0
_MAPTRIANGLE (0, 0)-(639, 479)-(639, 0), Image TO(100, 0)-(639, 479)-(540, 0), 0


Attached Files Image(s)
   
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply
#3
Why didn't you turn it around? Just add what's missing at the top to the bottom so that you have the whole thing at the top?

Code: (Select All)

Dim Image As Long
Image = _LoadImage("si.png", 32)

R = 100
Screen _NewImage(640, 480, 32)
_MapTriangle (0, 0)-(0, 479)-(639, 479), Image To(100 - R, 0)-(0 - R, 479)-(639 + R, 479), 0
_MapTriangle (0, 0)-(639, 479)-(639, 0), Image To(100 - R, 0)-(639 + R, 479)-(540, 0), 0


Reply
#4
The image is stilled skewed weird though for me. Is it ok for you? The image below is what I get with your code.


Attached Files Image(s)
   
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply
#5
Well, I thought I was being smart in thinking three tirangles were needed. Use the same image in my post above. It's closer, but still wonky. (image attached below is the result)

Code: (Select All)
DIM Image AS LONG
Image = _LOADIMAGE("si.png", 32)
SCREEN _NEWIMAGE(640, 480, 32)
_MAPTRIANGLE (0, 0)-(0, 479)-(319, 479), Image TO(99, 0)-(0, 479)-(319, 479), 0
_MAPTRIANGLE (639, 0)-(319, 479)-(639, 479), Image TO(540, 0)-(319, 479)-(639, 479), 0
_MAPTRIANGLE (0, 0)-(319, 479)-(639, 0), Image TO(99, 0)-(319, 479)-(540, 0), 0


Attached Files Image(s)
   
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply
#6
Really, output is not good. So then you can use hardware images, output is better. 

Code: (Select All)

Dim Image As Long
Image = _LoadImage("si.png", 32)
ih& = _CopyImage(Image, 33)

Screen _NewImage(640, 480, 32)


Do Until _KeyHit = 27
    _MapTriangle (0, 0)-(0, 479)-(639, 479), ih& To(-2, 2, -3)-(-2, -2, -1)-(2, -2, -1), 0
    _MapTriangle (0, 0)-(639, 479)-(639, 0), ih& To(-2, 2, -3)-(2, -2, -1)-(2, 2, -3), 0
    _Display
    _Limit 20
Loop


[Image: image.png]
it's just that it gets a little more complicated, the movement of the game will run in the virtual software screen and it will be copied as a hardware screen. Yeah, it's a little complicated. I tried with MapTriangle (2D) to figure out why it distorts, I couldn't figure it out.


Reply
#7
To the question above - motion of the stars - here is the solution in the form of a hardware image - it shows how to get the motion into the hardware image.

Code: (Select All)

Dim Image As Long
Image = _NewImage(640, 480, 32)
_Dest Image
Cls
For s = 1 To 100
    PSet (Rnd * 640, Rnd * 480)
Next

Virtual = _NewImage(640, 480, 32)

Screen _NewImage(640, 480, 32)

Do Until _KeyHit = 27
    xs = xs + 1
    If xs > 639 Then xs = 0
    _PutImage (xs, 0), Image, Virtual, (0, 0)-(639, 479)
    _PutImage (-639 + xs, 0), Image, Virtual, (0, 0)-(639, 479)

    ih& = _CopyImage(Virtual, 33)

    _MapTriangle (0, 0)-(0, 479)-(639, 479), ih& To(-2, 2, -3)-(-2, -2, -1)-(2, -2, -1), 0
    _MapTriangle (0, 0)-(639, 479)-(639, 0), ih& To(-2, 2, -3)-(2, -2, -1)-(2, 2, -3), 0
    _Display

    _FreeImage ih&

    _Limit 20
Loop


Reply
#8
(03-30-2024, 11:02 PM)Petr Wrote: Really, output is not good. So then you can use hardware images, output is better. 

Code: (Select All)

Dim Image As Long
Image = _LoadImage("si.png", 32)
ih& = _CopyImage(Image, 33)

Screen _NewImage(640, 480, 32)


Do Until _KeyHit = 27
    _MapTriangle (0, 0)-(0, 479)-(639, 479), ih& To(-2, 2, -3)-(-2, -2, -1)-(2, -2, -1), 0
    _MapTriangle (0, 0)-(639, 479)-(639, 0), ih& To(-2, 2, -3)-(2, -2, -1)-(2, 2, -3), 0
    _Display
    _Limit 20
Loop


[Image: image.png]
it's just that it gets a little more complicated, the movement of the game will run in the virtual software screen and it will be copied as a hardware screen. Yeah, it's a little complicated. I tried with MapTriangle (2D) to figure out why it distorts, I couldn't figure it out.

Ah ha! A 3D component is needed. Thank you for figuring this out.
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply
#9
I can't wait to get to a PC and try these code samples! 

I'm wondering how to get the 3d scrolling of the background stars toward the player (kind of like that old Atari game Sky Raider but without the curved effect). Here's a mockup of the background:

[Image: space-invaders-3dish-mockup-1.png]

And a mockup of flying thru dust clouds:

[Image: space-invaders-3dish-mockup-2.png]

Thanks for playing with this, and Happy Easter 
(N/)
(..)
C(")(")
Reply
#10
(03-30-2024, 11:02 PM)Petr Wrote: Really, output is not good. So then you can use hardware images, output is better. 
...
[Image: image.png]
it's just that it gets a little more complicated, the movement of the game will run in the virtual software screen and it will be copied as a hardware screen. Yeah, it's a little complicated. I tried with MapTriangle (2D) to figure out why it distorts, I couldn't figure it out.
That's pretty good. Thanks for sharing this solution. 

(03-30-2024, 11:16 PM)Petr Wrote: To the question above - motion of the stars - here is the solution in the form of a hardware image - it shows how to get the motion into the hardware image.
Interesting. So I just need to change the scrolling direction to down, then have it use the map triangle to skew it into pseudo 3d. 
I'll give it a try. . . Thanks again
Reply




Users browsing this thread: 10 Guest(s)