News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Birds game

Started by avcaballero, July 10, 2022, 08:26:36 AM

Previous topic - Next topic

avcaballero

The game is done.

Full Masm 32 bits + GDI source code. No external dll or lib used. Everything used is in my web page freely downloable.

Some birds flying here and there shit in your garden. You have a ball to convince them to do it in the neighbor's garden.

You have a score account and a seconds counter. When this counter reaches zero it should be game over, it's on the to-do list.

The ball describes a parabola. If it hits a bird, it will increase the marker by more the farther away the bird is.

Known bug: After a few shots, the motion of the ball speeds up. [Fixed]

jj2007

Looks lovely :thumbsup:

Wouldn't sky.png (4415 bytes) instead of sky.bmp (921654 bytes) be a better choice? Same for the birds, they could be one gif file...

Biterider

Hi Caballero
Looks very good!
I'm looking forward to the finished game.  :thumbsup:

Biterider

avcaballero

Hi, thank you for testing it.  :thumbsup:

I don't use any external routine to read image files, I read them "by hand" and bmp files are one of the easiest to read, that's why I use them. I think I could avoid to use the sky.bmp painting the cloudy sky with my own routines but, since the original challenge was reading these two files, I'll leave it at that.

jj2007

For inspiration - with source ;-)

GuiParas equ "Birds", w500, h320, b none
include \masm32\MasmBasic\Res\MbGui.asm
  SetGlobals SDWORD bird1X, bird1Y, bird2X, bird2Y, d1y, d2y
  mov eax, GuiHeight
  sar eax, 1
  sub eax, 30
  mov bird1Y, eax
  add eax, 60
  mov bird2Y, eax
Event Paint
  GuiImage "sky.png", fit
  GuiImage "tweety.gif", bird1X, bird1Y, 60, 60
  GuiImage "tweety.gif", bird2X, bird2Y
Event Timer
  sub bird1X, 5
  .if bird1X<-60
m2m bird1X, GuiWidth
  .endif
  sub bird2X, 4
  .if bird2X<-60
m2m bird2X, GuiWidth
  .endif
  sub Rand(11), 5
  add eax, d1y
  add bird1Y, eax
  .if bird1Y<20
dec d1y
  .elseif bird1Y>250
inc d1y
  .endif
  sar eax, 1
  inc eax
  .if bird2Y<20
dec d2y
  .elseif bird2Y>250
inc d2y
  .endif
  add eax, d2y
  sub bird2Y, eax
  GuiCls
GuiEnd

avcaballero

I have fixed some issues:

   - The birds in the background are always slower than the ones in the foreground. This gives a greater sense of depth.

   - When it came to regenerating the birds that were lost, it was not done well because I had to multiply the x-dim of the sprite by 10 because stretching generated decimals.
   
   x The ordering of the three layers of birds does not seem to be working well in all cases. It cannot be that a smaller bird passes in front of a larger one. In to-do list.

avcaballero

jj, where is the source? There's an include that I don't have. Do you use for reading/stretching images?

jj2007

Quote from: caballero on July 10, 2022, 09:41:23 PM
jj, where is the source? There's an include that I don't have.
Part of MasmBasic

QuoteDo you use for reading/stretching images?

For reading, I use mostly GdipCreateBitmapFromStream
For zooming, I use GdipDrawImageRectRectI

I really posted it just for inspiration. Yours looks better :thumbsup:

avcaballero

Nah, yours is nice too.  :thumbsup:

I don't use any external routine to read/zooming an image, I like to code it by myself.

avcaballero

The sorting method seems to be working now. None smaller bird should appear before a bigger one.

Greenhorn

Great stuff, caballero !  :thumbsup:

> The next step would be to draw a ball that would take a parabolic shot to the bottom to hit the bird, adding a score counter to it.
Reminds me a little bit on "Moorhuhn" game.  :biggrin:
Kole Feut un Nordenwind gift en krusen Büdel un en lütten Pint.

avcaballero

Thanks, Greenhorn  :thumbsup:. Moorhuhn reminds me Super Mario.

jj2007

Version 2, playing around with some new features, mainly zoom and RotateFlip :tongue:

Event Paint
  GuiImage 97, fit                             ; sky.png
  GuiImage 98, bird1X, bird1Y, size1, size1    ; tweety.gif
  GuiImage 98, bird2X, bird2Y                  ; tweety again
  GuiImageSet z=zoom3, rf=b3RF                 ; RotateNoneFlipX when going out of the screen
  GuiImage "https://jj2007.eu/pics/eagle.gif", bird3X, bird3Y, 200, 200


That was the "simple" part - the logic of the movements is trickier, see attached source :cool:

97+98 are resource IDs. The eagle was too fat to be included, so I put it on my page.

avcaballero

Balls with clipping tests. The ball is not from any image file, but made on the fly using math algos, this way we get a smaller exe. Since I don't use any external routine to draw the sprites, I have to do the clipping by myself, the same for the birds.

avcaballero

Now, you may move the ball around the screen with the mouse cursor, yet still cannot be shooted. Since the ball is at the user level, I have to add another layer for it. The ball, when shooted, will cross several layers, hence some birds must appear before and other behind it.

When finished, with the m'left button you'll shoot and with the m'right increase the angle.