The Re-Make of Alien Dropout ZX81

Started by Baggey, November 09, 2024, 18:05:59

Previous topic - Next topic

RemiD

#45
i have just realized that with the new detect collision system, (using 2d linepick and 2d outlines (made of 2d lines) ), we can simplify the code a lot, because we can have one image for the spaceship (with emptys and walls).
and then we have to define all the necessary lines which compose the outline of the walls. (i use an image editor to know what are the start point and the end point of each line).

this is even better that what i wanted to do before (with a kind of 'rectangle overlaps other rectangle'), because we can use any arbitrary shape for the walls.

i am working on that, and then i will report if this works well or not...

RemiD

#46
to create the outlines (made of 2d lines) for each shape, faster, i have coded a procedure which analyzes the pixels in a 'dots image' (one for each shape).
and identifies the 'dots' which are not black (nothing) and not mediumgrey (walls, hard stuff).
the remaining colors are pairs of 'dots' which are the extremities (2d points) of each 2d line composing the outline.
so that i only have to draw some dots (one color for each pair of dots, to represent the extremities of a 2d line) in an image editor, and this will retrieve the extremities (2d points) of each 2d line, automatically, and then write a 'shape.lines' binary file which stores the properties of all 2d lines of the outline for this shape.
then we only have to read this 'shape.lines' binary file, to retrieve the properties of all 2d lines of the outline for this shape.
so there will be less code to type manually ;D

in order to convert this code, you will have to understand :
-how to read the pixels of an image ( position and color )
-how to write pixels on an image ( position and color, for debugging )
-how to write values (integers and floats) to a binary file.
-how to read values (integers and floats) from a binary file.

so try to learn how to do that, if you don't know already...

RemiD

#47
2d linepick on 2d outlines (made of 2d lines) works well to detect a collision and get the collision 2d point and the collision 2d normal.

and this allows to detect collision between small turning moving entities and arbitrary shapes.

however what happens when a big obstacle also moves ( in this case, the spaceship ) ?

what if a bullet moves, goes in a 'shute', no collision is detected, but then the spaceship moves ? in this case the bullet would go through the walls of the spaceship...

one way to prevent that would be to not move the spaceship (like in the original game),
or to move the spaceship very slowly,
or maybe to have several rectangle areas, childs of the spaceship, which we can use to check if a bullet is inside a wall ?
or maybe to draw the spaceship on the backbuffer, then read the pixel(s) which correspond to the position / area of the bullet, and if they are of the color of a wall, destroy the bullet ?

we will keep it simple for this remake. ( not move the spaceship, or move it very slowly)

but this is something to think about for others games...

RemiD

#48
here is the last version, i have recoded everything so that all shapes have an outline (made of 2d lines), and we can detect collisions using 2d linepick and outlines (made of 2 lines) :
http://rd-stuff.fr/blitz3d/alien-dropout-2d-BB-20241121-1154.7z

-the spaceship can move up down left right.
-the alien can move left right inside the spaceship, it is a child of the spaceship so it translates with it.
-the ground can move up down.
-the turret can move left right on the ground, it is a child of the ground so it translates with it.
-the spaceship (or alien) can drop a pod or a bomb.
-the pods and the bombs are guided by the shutes, and when they come out they move freely.
-the turret can shoot a bullet or a rocket.
-the bullets and rockets move freely.

i let you take a look at all that, convert this code in blitzmax.

you will notice that i have added some code to debug the center position of each shape, and the outline (made of 2d lines) of each shape.
this is only for debuging and we will put that in comments, later...

on my side i am going to work on what happens when a pod, a bomb, a bullet, a rocket, has a collision with an obstacle, and the resulting explosions and impacts. (and damage)
i also have to code the ai for the alien so that 'he' will drop the pods and the bombs.

;D

RemiD

#49
ok, the collisions detection is a little buggy for this game (because calculating intersections between straight vertical lines is not possible...), but i have found a workaround by adding a random xoffset to the end point of the 2d linepick, and it works well enough to detect intersections.

-the bullets can hit the spaceship, the alien, the pods, the bombs, and this create impacts and particles.
-after a pod, a bomb, the alien, has been hit several times, it is destroyed.

@Baggey>>
can you explain with more details :

-what is a 'pod', and what they should do when they reach the ground ( create a circular explosion ? or spread a liquid ? or what ? )

-what is a 'bomb' and what they should do when they reach the ground ( create an horizontal explosion ? )

thanks,

Baggey

Quote from: RemiD on November 23, 2024, 11:50:32ok, the collisions detection is a little buggy for this game (because calculating intersections between straight vertical lines is not possible...), but i have found a workaround by adding a random xoffset to the end point of the 2d linepick, and it works well enough to detect intersections.
-the bullets can hit the spaceship, the alien, the pods, the bombs, and this create impacts and particles.
-after a pod, a bomb, the alien, has been hit several times, it is destroyed.
@Baggey>>
can you explain with more details :
-what is a 'pod', and what they should do when they reach the ground ( create a circular explosion ? or spread a liquid ? or what ? )

The Pod is the alien Space ship that drops from the shutes. When it his the ground it cause's a sideways explosion of 2 Character blocks or 16 pixels either side.


-what is a 'bomb' and what they should do when they reach the ground ( create an horizontal explosion ? )

The Bomb aka SmartBomb is the one dropped by the Alien Mothership/Flying Saucer. It Destroys all the terrain/ horizontal explosion and you that's why you must shoot it.

thanks,
Running a PC that just Aint fast enough!? i7 4Ghz Quad core 32GB ram  2x1TB SSD and NVIDIA Quadro K1200 on Acer 24" . DID Technology stop! Or have we been assimulated!

Windows10, Parrot OS, Raspberry Pi Black Edition! , ZX Spectrum 48k, C64, Enterprise 128K, The SID chip. Im Misunderstood!

RemiD

#51
@Baggey>>
ok

and what should happen when a bullet destroys a pod ? or when a bullet destroys a bomb ?

same kind of explosions but in the air ? for now it just spreads particles of the color of the shape which is hit.

anyway, the version of the game that i am making will not be the exact same graphics style / shapes sizes / gameplay / effects, than in the original game, as you may have noticed...

i think that the original game could be made with a much simpler code than what i have done.
but this is just how i would do it, and some of the functions / procedures provided can be used for others more complex 2d games... so it will give you some ideas...

Baggey

Quote from: RemiD on November 23, 2024, 19:41:08@Baggey>>
ok

and what should happen when a bullet destroys a pod ? or when a bullet destroys a bomb ?

They just get vapourised / Blown up! I would suggest getting extra points for shooting Pod when it has been released. And may be every Smart Bomb shot in the same play will double in score as a level clearance bonus?

same kind of explosions but in the air ? for now it just spreads particles of the color of the shape which is hit.

That's fine.

anyway, the version of the game that i am making will not be the exact same graphics style / shapes sizes / gameplay / effects, than in the original game, as you may have noticed...

That's Fine again! It's for Fun and Learning ;)

i think that the original game could be made with a much simpler code than what i have done.
but this is just how i would do it, and some of the functions / procedures provided can be used for others more complex 2d games... so it will give you some ideas...

As we say. There are always more than one way's to skin a Cat! :-X

To me if it works! and is Playable speed wise, who cares how it's been done?  :-\

Kind Regards Baggey
Running a PC that just Aint fast enough!? i7 4Ghz Quad core 32GB ram  2x1TB SSD and NVIDIA Quadro K1200 on Acer 24" . DID Technology stop! Or have we been assimulated!

Windows10, Parrot OS, Raspberry Pi Black Edition! , ZX Spectrum 48k, C64, Enterprise 128K, The SID chip. Im Misunderstood!

RemiD

#53
@Baggey>>
ok

my ideas are :
-1 bullet is necessary to destroy a pod.
-10 bullets (or 1 rocket) are necessary to destroy a bomb.
-when a pod is destroyed while in the air, it spreads particles of its shell and of its content.
-when a bomb is destroyed while in the air, it spreads particles of its shell and of its content.
-when the pod hits the ground, it provokes a small circular explosion (which can damage the turret).
-when the bomb hits the ground, it provokes a big horizontal explosion, (which can destroy the turret).
-the alien can be hit / damaged by a bullet or by the explosion of a rocket.
-the game ends when either the alien is destroyed or the turret is destroyed.

i am going to implement all of that.

and then i will share this new version.

and then you can use this as an example to have ideas on how to implement it on your side.

i think that the detect collisions could be done with a simpler system ( rect overlap other rect ) but i am not sure if it is possible to get a precise collision point and a correct collision normal with such approach.
i would have to experiment with that...

Baggey

Running a PC that just Aint fast enough!? i7 4Ghz Quad core 32GB ram  2x1TB SSD and NVIDIA Quadro K1200 on Acer 24" . DID Technology stop! Or have we been assimulated!

Windows10, Parrot OS, Raspberry Pi Black Edition! , ZX Spectrum 48k, C64, Enterprise 128K, The SID chip. Im Misunderstood!

RemiD

one limitation that i have in blitzbasic / blitz3d, is that, in 2d we work with images (not textures) and images don't have a variable opacity / transparency (alpha), only fully opaque or fully transparent.

so for explosions i change the color from light color to dark color. but with blitzmax you can change the alpha of each image, if i remember correctly.

we can also achieve that in blitz3d by using textured rectangles meshes, modeled in a way, and uvmapped in a way, and positionned in a way (from the camera), that one texel would appear to have the same size than one pixel.
for example : https://www.syntaxbomb.com/blitz2d-blitzplus-blitz3d/help-error-somewhere-to-position-a-quad-precisely-at-mousex-mousey/

RemiD

#56
ok, i have almost finished the remake of this 'alien dropout' game, with the essential things / entities and gameplay possibilities,

if i would have to simplify something, it would be the way to detect collisions, for this game i have chosen to use 2d linepick on 2d outlines (made of 2d lines), but since the projectiles go only up or only down in this game, i could have used a 'rect overlap other rect' (area overlap other area) way to detect collisions.

for the score, i have implemented this :
-there is an alien score and a player score.
-the alien gains some points when a pod explodes on the ground, when a bomb explodes on the ground, when the turret is destroyed (by the damages of a pod/bomb).
-the alien loses some points when droping a new pod, when droping a new bomb.
-the player gains some points when a pod is destroyed (by the damages of bullet/rocket), when a bomb is destroyed (by the damages of bullet/rocket), when the alien is destroyed (by the damages of bullet/rocket).
-the player loses some points when shooting a new bullet, when shooting a new rocket.
-the final score is equal to player score - alien score.

of course it can always be improved depending on your ideas and tastes.

i just have to finish to edit the sounds and to add the code to play the sounds.

then i will post the last version.

there will be no title screen, no intro screen, no menu screen, no score screen, no credits screen, you would have to implement this on your side.

Baggey

Quote from: RemiD on November 30, 2024, 10:07:39ok, i have almost finished the remake of this 'alien dropout' game, with the essential things / entities and gameplay possibilities,

if i would have to simplify something, it would be the way to detect collisions, for this game i have chosen to use 2d linepick on 2d outlines (made of 2d lines), but since the projectiles go only up or only down in this game, i could have used a 'rect overlap other rect' (area overlap other area) way to detect collisions.

why not just have an x,y grid Array and when x=x and y=y + what ever the pixel size is we have a hit!? Im not sure how it's done but that's me thinking from outside the box? :-X

for the score, i have implemented it this :
-there is an alien score and a player score.
-the alien gains some points when a pod explodes on the ground, when a bomb explodes on the ground, when the turret is destroyed (by the damages of a pod/bomb).
-the alien loses some points when droping a new pod, when droping a new bomb.
-the player gains some points when a pod is destroyed (by the damages of bullet/rocket), when a bomb is destroyed (by the damages of bullet/rocket), when the alien is destroyed (by the damages of bullet/rocket).
-the player loses some points when shooting a new bullet, when shooting a new rocket.
-the final score is equal to player score - alien score.

of course it can always be improved depending on your ideas and tastes.

i just have to finish to edit the sounds and to add the code to play the sounds.

then i will post the last version.

there will be no title screen, no intro screen, no menu screen, no score screen, no credits screen, you would have to implement this on your side.

Running a PC that just Aint fast enough!? i7 4Ghz Quad core 32GB ram  2x1TB SSD and NVIDIA Quadro K1200 on Acer 24" . DID Technology stop! Or have we been assimulated!

Windows10, Parrot OS, Raspberry Pi Black Edition! , ZX Spectrum 48k, C64, Enterprise 128K, The SID chip. Im Misunderstood!

RemiD

#58
Quotewhy not just have an x,y grid Array and when x=x and y=y + what ever the pixel size is we have a hit!? Im not sure how it's done but that's me thinking from outside the box?

ok, why not, but how would you manage when the spaceship moves (and its 'childs' : the alien, the pods, the bomb, which are inside), and when the ground moves, (and its 'childs' : the turret which is on).

because i have not coded an exact same remake, but a slightly improved remake ;)

and also because i am used to work with 3d, so i have tried to detect collisions in 2d like we detect collisions in 3d (using 3d linepicks and 3d meshes).

and also because i wanted to show a way to get a precise collision point and collision normal on an outline of a 2d shape (made of 2d lines), which can be useful for some games / some effects, which you can't achieve with a 2d grid or with a 'rect overlaps other rect' ('area overlaps other area').

you are free to code your own remake of this game as you want, this is just my way to do it !

RemiD

Quoteand also because i wanted to show a way to get a precise collision point and collision normal on an outline of a 2d shape (made of 2d lines), which can be useful for some games / some effects
i have coded this way to detect collisions in 2d when i worked on my 'breakout 2d' game,
because i needed to get a precise collision point and collision normal.
see : https://www.syntaxbomb.com/worklogs/breakout-2d-arcade-game/

i will have to finish it someday ^-^