New game Dogsheep

Discussions related to graphics (2D and 3D), animation and games programming
jgroenendaal
Posts: 23
Joined: Fri 15 Nov 2024, 14:40

New game Dogsheep

Post by jgroenendaal »

Hello all,

After Richard is converting one of my BBC Basic for Windows Joop into BBCSDL, I rechecked some other BBC Basic project I created previously.
And I decided to write again a new game in BBCSDL.

Before I will start into building a big game project, I will built a small game to relearn myself to make games, which I didn't do for a couple of years.

I will start with remaking an old game magazine game I really liked on the Acorn Electron.
You can still play it here online : https://www.bbcmicro.co.uk/game.php?id=4407
From here, it's easy to get the original BBC Basic source, and with some small timing adjustments you can run and play it with BB4W or BBCSDL.

So to start making this game we need some sprites. I decided to make the sprites 48 x 48 pixels, while I will place them on a grid of 32 x 32.
This to make some more natural and smooth overlap, like the grass on the foreground of a fence or sheep.

I created some sprites within a few hours. So these are not the most beautiful, they will work to see if the approach to create it tshis way is correct. Maybe I will make better graphics later on.

Image

Now, we can do some coding in BBC SDL.

As I decided to put larger sprites in a smaller grid, every sprite texture contains an offset x and y for proper drawing.
This is done in the DIM Sprite that included the Texture and the Offset X and offset Y.

I also created the grid area of 20 x 19 positions having an surface layer for grass and maybe later additional surfaces like flowers, water and an object layer that will hold the fences and perhaps rocks or other things if I will extend this test game.

So today, I managed to fill the game area with the random grass as a start.

Image

It's nice to code again in BBC Basic.
Suggestion, questions and remarks are always welcome.
I hope I can finish some next steps during the weekend.

For now the BBC Basic code looks like :


10 REM Kaisy
20 REM for testing game creation with BBC SDL
30 REM (p) Jeroen Groenendaal
40 :
50 INSTALL @lib$+"gfxlib"
60 PROC_gfxInit
70 OFF
80
90 DIM Sprite{Texture%,OffsetX%,OffsetY%}
100
110 DIM surface{(9)}=Sprite{}
120 DIM area{(19,18) surface%,object%}
130
140 FOR X=0 TO 19
150 FOR Y=0 TO 18
160 area{(X,Y)}.surface%=RND(2)-1
170 NEXT Y
180 NEXT X
190
200 surface{(0)}.Texture%=FN_gfxLoadTexture(@dir$+"gras1.png",0)
210 surface{(0)}.OffsetX%=-6
220 surface{(0)}.OffsetY%=-6
230 surface{(1)}.Texture%=FN_gfxLoadTexture(@dir$+"gras2.png",0)
240 surface{(1)}.OffsetX%=-6
250 surface{(1)}.OffsetY%=-6
260
270 *REFRESH OFF
280
290 REPEAT
300 TIME=0
310 FOR X=0 TO 19
320 FOR Y=0 TO 18
330 S = area{(X,Y)}.surface%
340 PROC_gfxPlotScale(surface{(S).Texture%,48,48,(32*X)+surface{(S).OffsetX%,(32*Y)+surface{(S).OffsetY%)
350 NEXT Y
360 NEXT X
370 PRINTTAB(0,0);TIME
380 *REFRESH
390 UNTIL FALSE
Richard Russell
Posts: 272
Joined: Tue 18 Jun 2024, 09:32

Re: New game Dogsheep

Post by Richard Russell »

jgroenendaal wrote: Fri 15 Nov 2024, 18:23 So to start making this game we need some sprites. I decided to make the sprites 48 x 48 pixels, while I will place them on a grid of 32 x 32.
This to make some more natural and smooth overlap, like the grass on the foreground of a fence or sheep.
That's probably a good idea, but I wouldn't expect such a large overlap to be necessary. Something like a 36 x 36 sprite should provide sufficient overlap to eliminate 'boundary effects', I would have thought.

I noticed that in Joop the sprites are contained within .gek files, rather than using individual (e.g. .png) images. By reducing the number of small resource files this improves the storage efficiency. Vapiki, however, seems to use a large number of .bmp images, is there a reason for that difference?
jgroenendaal
Posts: 23
Joined: Fri 15 Nov 2024, 14:40

Re: New game Dogsheep

Post by jgroenendaal »

Hello,
Richard Russell wrote: Sat 16 Nov 2024, 18:14 That's probably a good idea, but I wouldn't expect such a large overlap to be necessary. Something like a 36 x 36 sprite should provide sufficient overlap to eliminate 'boundary effects', I would have thought.
Yes. But the sheeps are using almost the full width of 48 pixels.
For the grass it is not very important so these could be a bit smaller, but with some grassblade I will keep it.

With the progress of this game, I currently added some level storage, and I have now two sheeps as a test blinking with the eyes randomly.
I also tested the ability to deploy bbb files online, with good luck :
https://wasm.bbcbasic.net/bbcsdl.html?a ... /kaisy.bbb

The timer on the left corner indicated the sequence of each movement that takes place, if it's blinking eyes or movement of the sheep or dog. It should all happen in 1/4 of a second.
I am not sure if this idea holds .. But that's what I want ;) Just to keep the game play the same as the original.
Richard Russell wrote: Sat 16 Nov 2024, 18:14 I noticed that in Joop the sprites are contained within .gek files, rather than using individual (e.g. .png) images. By reducing the number of small resource files this improves the storage efficiency. Vapiki, however, seems to use a large number of .bmp images, is there a reason for that difference?
Yes, the work folders of Vapiki are a bit messy.

The game Vapiki uses the .gek files - like Joop. They are also existing in the vapiki folder.
As Vapiki partly uses some old GFXLibrary routines, the sprites of the level grid are stored as area.000 and area.001 containing the 24 RGB and 8 Alpha as separate files.
The massive amount of .bmp files and the separate Mask folder are still required for the Vapiki level editor.

The reason was that, when I decided to save other sprites as 32 BMP files, I discovered the new routines didn't working with MultiWin anymore.
To speed up, I only rewrote Vapiki to be working with the new 32 BMP files ( combined in the .gek folder ) and leaving the Vapiki Level Editor to load all sprites in the seperate files. With this decision, the output of the bundles graphics are also vertically flipped ( for the DirectX drawing routines ).

You can see in a distributed folder of Vapiki, what the final files that are required should be.
Richard Russell
Posts: 272
Joined: Tue 18 Jun 2024, 09:32

Re: New game Dogsheep

Post by Richard Russell »

jgroenendaal wrote: Sun 17 Nov 2024, 14:41 The game Vapiki uses the .gek files - like Joop. They are also existing in the vapiki folder.
As Vapiki partly uses some old GFXLibrary routines, the sprites of the level grid are stored as area.000 and area.001 containing the 24 RGB and 8 Alpha as separate files.
The massive amount of .bmp files and the separate Mask folder are still required for the Vapiki level editor.
Ah. This is is obviously rather more complicated than I realised! Is the "Vapiki level editor" a separate app intended for the end-user, or something that only you use? Can I ignore it (and all the .bmp files) if I attempt a conversion to BBCSDL?
jgroenendaal
Posts: 23
Joined: Fri 15 Nov 2024, 14:40

Re: New game Dogsheep

Post by jgroenendaal »

Richard Russell wrote: Sun 17 Nov 2024, 15:05 Ah. This is is obviously rather more complicated than I realised! Is the "Vapiki level editor" a separate app intended for the end-user, or something that only you use? Can I ignore it (and all the .bmp files) if I attempt a conversion to BBCSDL?
The Vapiki level editor, is not part of the end-user. I hope it's making things less complicated.
jgroenendaal
Posts: 23
Joined: Fri 15 Nov 2024, 14:40

Re: New game Dogsheep

Post by jgroenendaal »

I am doing little progress on the game.
I've got some movement in the sheeps.

https://wasm.bbcbasic.net/bbcsdl.html?a ... /kaisy.bbb
Richard Russell
Posts: 272
Joined: Tue 18 Jun 2024, 09:32

Re: New game Dogsheep

Post by Richard Russell »

jgroenendaal wrote: Tue 19 Nov 2024, 20:17 I've got some movement in the sheeps.

https://wasm.bbcbasic.net/bbcsdl.html?a ... /kaisy.bbb
Nice!
jgroenendaal
Posts: 23
Joined: Fri 15 Nov 2024, 14:40

Re: New game Dogsheep

Post by jgroenendaal »

Hello,

https://wasm.bbcbasic.net/bbcsdl.html?a ... /kaisy.bbb

The dog named Kaisy is now playable with the arrow keys as well.
The sheep to react on Kaisy and it's possible to get all sheep inside the fences.

Of course still some errors here and there. Sometimes the sheep jump over the fences if they are blocked - not something the shepherd wants to see.
I also synced the timing between the dog and the sheep - but that makes the movement of the dog delayed over the key pressed - not sure if that is a natural way of playing a game.

Anyway, the idea of the game is now a visible and playable.
jgroenendaal
Posts: 23
Joined: Fri 15 Nov 2024, 14:40

Re: New game Dogsheep

Post by jgroenendaal »

https://wasm.bbcbasic.net/bbcsdl.html?a ... /kaisy.bbb

This update is mainly if the game would be playable on touch devices.
jgroenendaal
Posts: 23
Joined: Fri 15 Nov 2024, 14:40

Re: New game Dogsheep

Post by jgroenendaal »

Hello,

https://wasm.bbcbasic.net/bbcsdl.html?a ... /kaisy.bbb

This test game has most tasks completed I wanted to archieve.
It now contains an hi-score, levels and some primitive sound samples.

That's it for this Dogsheep game I suppose. it's a nice test game to learn some basics of BBC Basic SDL.