CMM2 Defender Clone


Author Message
PeteCotton

Guru

Joined: 13/08/2020
Location: Canada
Posts: 369
Posted: 05:06pm 06 Sep 2020      

Here you go.

https://youtu.be/jgUyCZoqWgA

Unfortunately my camera didn't pick up the sound, but you're not missing much there - it's definitely the weak spot of the game.

I was really trying to get a good parallax going. I am very happy with the way the vertical parallax looks. It kicks in when the player is in the top half of the screen, I wanted to give the impression of rising up high over the mountains.

The player has three lives and I originally had it so that the game paused and restarted for a few seconds after each death, but this slowed down the game play. So I made it that the screen flashes each time the player collides with something, and on the third hit they explode. That caused issues if the player ran through a bunch of aliens and lost all three lives straight away, so the player now gets a 3 second shield of invulnerability each time they lose a life.

The 3 mountain ranges are drawn on one buffer screen. Each range is 1600 pixels wide and 100 pixels high. So mountain range 1 is on rows 0-100 and 101-200. Range 2 is on 201 to 300 and 301 to 400. And range 3 is on 401 to 500 and 501 to 600.

These are blitted on to the screen and stitched together to repeat indefinitely.


 
I drew the mountains in the program using a sin/cosine calculation - the type you would use for a 3d plot. And instead of drawing it in 3d, I plotted it sideways on. This took about 20 seconds during startup, so once I was happy with them I saved the bitmap to disk and removed the code (so now it just loads the screen on startup). If you noticed I plotted the mountains at different brightnesses to help with the depth illusion (further away = duller colours). I also plotted the foreground mountains with filled in polgons (filled with a dark green) so that they would do "hidden line removal" on the mountains ranges behind them.

Finally, for the 3d effect of the ground I again wrote a little plot function that would draw a 3D grid at 20 evenly spaced angles, and then depending on where the player is on the X-axis, I plot the appropriate one of these 20 steps, which gives the effect of the 3d scrolling ground.



I know it's hard to see with all of the images stuck together, so it might be clearer if I show a couple of them split out.


 
If I can answer any other questions, I would be more than happy to. Thank you for all of the positive feedback. It is appreciated.

P.S. Despite the video, I can actually play the game better than that, but I was balancing the keyboard on one knee while peering around the back of the camera :-D
Edited 2020-09-07 03:11 by PeteCotton