Author Topic: Birds game  (Read 955 times)

caballero

  • Member
  • *****
  • Posts: 2034
  • Matrix - Noah
    • abre ojos ensamblador
Birds game
« on: July 10, 2022, 08:26:36 AM »
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]
« Last Edit: July 30, 2022, 01:43:38 AM by caballero »
The logic of the error is hidden among the most unexpected lines of the program

jj2007

  • Member
  • *****
  • Posts: 13304
  • Assembly is fun ;-)
    • MasmBasic
Re: Birds game
« Reply #1 on: July 10, 2022, 10:22:42 AM »
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

  • Member
  • *****
  • Posts: 1041
  • ObjAsm Developer
    • ObjAsm
Re: Birds game
« Reply #2 on: July 10, 2022, 03:06:14 PM »
Hi Caballero
Looks very good!
I'm looking forward to the finished game.  :thumbsup:

Biterider

caballero

  • Member
  • *****
  • Posts: 2034
  • Matrix - Noah
    • abre ojos ensamblador
Re: Birds game
« Reply #3 on: July 10, 2022, 05:50:29 PM »
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.
The logic of the error is hidden among the most unexpected lines of the program

jj2007

  • Member
  • *****
  • Posts: 13304
  • Assembly is fun ;-)
    • MasmBasic
Re: Birds game
« Reply #4 on: July 10, 2022, 09:13:07 PM »
For inspiration - with source ;-)

Code: [Select]
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

caballero

  • Member
  • *****
  • Posts: 2034
  • Matrix - Noah
    • abre ojos ensamblador
Re: Birds game
« Reply #5 on: July 10, 2022, 09:31:14 PM »
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.
The logic of the error is hidden among the most unexpected lines of the program

caballero

  • Member
  • *****
  • Posts: 2034
  • Matrix - Noah
    • abre ojos ensamblador
Re: Birds game
« Reply #6 on: July 10, 2022, 09:41:23 PM »
jj, where is the source? There's an include that I don't have. Do you use for reading/stretching images?
The logic of the error is hidden among the most unexpected lines of the program

jj2007

  • Member
  • *****
  • Posts: 13304
  • Assembly is fun ;-)
    • MasmBasic
Re: Birds game
« Reply #7 on: July 10, 2022, 10:23:20 PM »
jj, where is the source? There's an include that I don't have.
Part of MasmBasic

Quote
Do 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:

caballero

  • Member
  • *****
  • Posts: 2034
  • Matrix - Noah
    • abre ojos ensamblador
Re: Birds game
« Reply #8 on: July 10, 2022, 11:10:07 PM »
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.
The logic of the error is hidden among the most unexpected lines of the program

caballero

  • Member
  • *****
  • Posts: 2034
  • Matrix - Noah
    • abre ojos ensamblador
Re: Birds game
« Reply #9 on: July 11, 2022, 05:41:04 AM »
The sorting method seems to be working now. None smaller bird should appear before a bigger one.
The logic of the error is hidden among the most unexpected lines of the program

Greenhorn

  • Member
  • ***
  • Posts: 434
Re: Birds game
« Reply #10 on: July 13, 2022, 08:26:28 AM »
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.

caballero

  • Member
  • *****
  • Posts: 2034
  • Matrix - Noah
    • abre ojos ensamblador
Re: Birds game
« Reply #11 on: July 13, 2022, 07:39:13 PM »
Thanks, Greenhorn  :thumbsup:. Moorhuhn reminds me Super Mario.
The logic of the error is hidden among the most unexpected lines of the program

jj2007

  • Member
  • *****
  • Posts: 13304
  • Assembly is fun ;-)
    • MasmBasic
Re: Birds game
« Reply #12 on: July 13, 2022, 10:45:56 PM »
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.

caballero

  • Member
  • *****
  • Posts: 2034
  • Matrix - Noah
    • abre ojos ensamblador
Re: Birds game
« Reply #13 on: July 14, 2022, 09:10:09 AM »
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.
The logic of the error is hidden among the most unexpected lines of the program

caballero

  • Member
  • *****
  • Posts: 2034
  • Matrix - Noah
    • abre ojos ensamblador
Re: Birds game
« Reply #14 on: July 17, 2022, 02:21:04 AM »
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.
The logic of the error is hidden among the most unexpected lines of the program