DrGonzo 2021-01-26 16:24 (Edited)
'SPACE HARRIER INTENT
'BY NATHANIEL R. BABIAK, DRGONZO AND GREENPILLOZ
'SHOOTER ENGINE FROM LOWRESGALAXY2 BY TIMO
'LANDSCAPE DEMO 0.1, BY NATHANIEL R. BABIAK, ED. JANUARY 26, 2021.
V0.0: added ennemies to have something to shoot.
Player can’t be hit by enemy bullets.
V0.1: sprite optimization
V0.2: added music 8 first bars
V0.3: bullets direction fixed. Aliens spawn on screen center.
V0.4: missing enemy frame fixed
DrGonzo 2021-01-26 16:32
It’s just a demo, you only can move Harrier and shoot. I’ll just need a bit more room for sprites. Nevertheless Greenpilloz had a good idea to scale sprites using raster so maybe we can be fine with this amount.
DrGonzo 2021-01-26 16:40
Omg I’m so stocked about this I’ve been watching the animation and shooting randomly while singing the first stage tune for the past 20 minutes 😂
Roy___ 2021-01-26 16:43 (Edited)
Can you flip some of the existing sprites? I.e the left side sprite could be flipped for the right. Could you also halve some of the other sprites that are effectively a mirror image and draw then using an extra flipped sprite (the shadow for example.)
Be interesting to see if you can scale a sprite using the raster!
DrGonzo 2021-01-26 17:02
Hey Roy, here’s a rough example from greenpilloz, i hope he won’t get mad for sharing it ;)
nathanielbabiak 2021-01-26 17:13 (Edited)
To reduce your character usage well below the system budget:
In the same line of thought as that second bullet, you should put your first 32x32 sprite on page 1 at cell 0, because your first sprite has a blank left-column. The upper-left 8x8 cell of that sprite will pull double-duty - it's blank so it can act as char-0. This frees up a whole cell for more graphics later on.
nathanielbabiak 2021-01-26 17:20
The second bullet can be applied immediately to page 4 in the Gfx editor. But, it can also be applied to page 3 if you shift the pixels of the graphics.
nathanielbabiak 2021-01-26 17:35 (Edited)
As far as game-comments go...
The 3D thing... even though the horizon line is at PY=72, that only represents draw distance (required because of anisotropic effects). The vanishing point of the lines on the landscape is at PY~=57.5. Basically I'm saying I noticed the bullets move towards the center of the screen a bit more than necessary as they move away from the avatar. (They should glide overtop the landscape lines and follow them.)
I'd recommend having an X, Y, and Z value for the bullets (and basically every sprite in the game), each of these having units of pixels, and each of these being at the sprite's center, not upper left corner. To "map" these points from 3D
(X,Y,Z) to 2D use
(X*GZ0/Z,Y*GZ0/Z), it's super easy because I've defined
GZ0 in the code already. Note that this 2D coordinate is in "flat" space (origin near the middle of the screen, not PX,PY space (origin at the upper-left corner of the screen).
Note this means that, when Z=GZ0, the X and Y values don't change at all.. it also means the screen itself is at a Z value of GZ0, around 104 if I recall correctly. That means it's 104 pixels from the eye of the person playing your game to the screen they're holding or looking at.
nathanielbabiak 2021-01-26 17:41
Again, just trying to be super-clear. Personally, it blows my mind that pixels can be measured in the z direction AND it blows my mind that pixels can be measured in real-world space.
nathanielbabiak 2021-01-26 17:42
Here's a nice benefit of changing the 3D mapping in your game... enemies won't need to originate out of a pin-hole in the center of the screen ;-)
DrGonzo 2021-01-26 17:44
Ty for all the ideas guys. Yeah the sprites are rather wide atm as I organised them to be easily found in hex, to import in your program. Indeed I’ll do as much mirror as possible. And reuse what I can. I just plan to add 2 types of ennemies. Rocks, trees, columns. No bosses
Roy___ 2021-01-26 17:44
Definitely some space to be saved as Nathaniel has pointed out.
DrGonzo 2021-01-26 17:46
Ok it’s a lot of information to process give me a minute ;)
Roy___ 2021-01-26 17:49
You can also scale a background layer using the raster - no idea if that can be used for anything? Maybe a bigger, single object like a boss? Still no easy horizontal scaling and you’d obviously need the char space!
nathanielbabiak 2021-01-26 17:49
Yeah dude - it is! I haven't been active in a while because I'm writing an OpenGL implementation for this system... 3D graphics are crazy hard.
DrGonzo 2021-01-26 18:02
I’m having a hard time conceiving the z value. I noticed your comments whether it was necessary or not for the game in the program. And I thought you were more eager than me to decide. In regard to the bullets, It felt to me that I kinda mesured it using the frame/bullet counter named FRB.
DrGonzo 2021-01-26 18:06
@roy: that’s a great idea. I was kinda thinking of drawing the dragon like this
nathanielbabiak 2021-01-26 18:10 (Edited)
It's the "left-handed" one here.
The arrow to the right is X, the arrow up is Y, the arrow forward is Z. In that pic, the three arrows meet at the center of the screen. Due to the mathematical model that's the basis for this specific 3D landscape, the "center" of the screen is at PX=80, PY=57.5.
nathanielbabiak 2021-01-26 18:13 (Edited)
The point (0,0,0) is the biological eyeball of the person looking at your game
on the screen. The point (0,0,GZ0) is at the "center" of the screen at PX=80,PY=57.5,Z=GZ0... meaning the z value is at exactly the depth of the screen from the biological eyeball (around 104 pixels between the eyeball and screen).
Flat points (with any X and Y values but always Z=GZ0) will lie "on" the screen. 3D points (with any x and y values but Z>GZ0) will always be at a depth past the screen.
nathanielbabiak 2021-01-26 18:16
The source code that's commented-out doesn't actually work... yet. It's just placeholder for implementing rotating the camera pitch, and also infinite left-right strafing.
DrGonzo 2021-01-26 18:44 (Edited)
Hey ty. It actually feels clearer now. Im experimenting with the (X*GZ0/Z,Y*GZ0/Z) formula, but I’m not sure of what I’m expecting. I have to base with Greenpilloz, as he’s the smart one, and he will help me process it in my simpler mind! you know it’s funny because this morning he already had sent me a similar document explaining me this
nathanielbabiak 2021-01-26 18:59 (Edited)
The formula creates a vanishing point, see here.
Just check out the pictures in the article :-)
nathanielbabiak 2021-01-26 19:06
Think about what happens as z approaches infinity - the denominator... dominates, and so the coordinate goes to (0,0). BUT, that coordinate is near the center of the screen in "flat" coordinates, not pixel coordinates
nathanielbabiak 2021-01-26 19:09
Note that, because the landscape is below the vanishing point, the 3D y value of the landscape plane is actually negative... it's located at -72... as in 72 pixels below the biological eye line
Greenpilloz 2021-01-26 20:02
No point in using actual 3D coordinates here imho. Unless you implement changing the field of view as in harrier for Nintendo 3DS or other recent consoles, the vanishing point was fix (and the ground was probably just three alternating already-drawn backgrounds). So, all trajectories and lines are going straight toward the vanishing point (or center in our case).
DrGonzo 2021-01-26 23:49
Changing the field of view would be really cool though.
CubicleHead 2021-01-27 15:21
This is very cool!
Greenpilloz 2021-02-03 11:31
Sorry I was wrong 3D coordinates is the way to go !
I actually haven't played this game earlier and I just checked the nes version that is the most crappy one. I tried as recommended by @DrGonzo the 32X one and Its the bomb !
It would be really cool indeed to be able to strafe right and left and go up and down with the perspective changing as your code might be able to do, but I couldn't manage to modify it myself for this effect to work.
I modified DrGonzo's code to use 3D coordinates as explained in one of your posts and we applied it to obstacles and bullets. However, there are still some issues with the code atm.
I am playing also with the possibility to do smooth zooming with raster effect but it might be too demanding for the raster subroutine as it is also needed for the landscape. If anybody is interested in zooming with raster here is the testing code
-SkyLock24- 2021-02-14 15:06
Reminds me of the Contra games for the NES
WhyCanInotThinkOfAName? 2021-03-17 21:58
WOW! i had no idea nx could handle 3d scrolling. THIS IS SO COOL
nathanielbabiak 2021-03-18 00:40 (Edited)
Thanks! It's based on an older version of my upload that now has infinite strafing
here. (Edited: I took my old example down (I don't like posting incomplete stuff) since my new stuff is better.)
If you're interested in 3D (just to see what NX is capable of), you can also check this out, but keep in mind LowRes NX is focused on sprite and tilemap based display, so in addition to requiring a ray casting engine, this also uses a pixel-level display driver. It's not really a teaching tool, just a demo.
nathanielbabiak 2021-08-24 04:20 (Edited)
I've improved my previous landscape math that "powers" this upload, it's in my raster racer here. Check it out!