Lady Bug

developing/porting a new game or gaming framework? post in here!
SteveF
Posts: 935
Joined: Fri Aug 28, 2015 9:34 pm
Contact:

Re: Lady Bug

Post by SteveF »

Thanks, that makes sense! I understand it's all work in progress, I just thought I'd better mention it in case you didn't already know about it. Looking forward to the next update!
User avatar
lovebug
Posts: 182
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

SteveF wrote:
Sun Apr 04, 2021 10:46 pm
Thanks, that makes sense! I understand it's all work in progress, I just thought I'd better mention it in case you didn't already know about it. Looking forward to the next update!
I really appreciate that you pointed it out as it could have been something I had missed, thanks :)
ImageImage
Experimental random joke every 60 seconds (refresh page)
User avatar
lovebug
Posts: 182
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

I think ive just written the worlds worst aiming logic :-&
ladybug.ssd
(9.25 KiB) Downloaded 8 times
ImageImage
Experimental random joke every 60 seconds (refresh page)
User avatar
lovebug
Posts: 182
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

slightly better ? lol
ladybug.ssd
(9.25 KiB) Downloaded 6 times
ImageImage
Experimental random joke every 60 seconds (refresh page)
User avatar
lovebug
Posts: 182
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

follows well when behind ladybug but easily gets stuck
hmmmm
ladybug.ssd
(9.25 KiB) Downloaded 6 times
ImageImage
Experimental random joke every 60 seconds (refresh page)
User avatar
lovebug
Posts: 182
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

omg I tried many things and its all crap ! =D> =D> =D> =D> =D>

I shouldnt try to write enemy aim logic when im tired
ImageImage
Experimental random joke every 60 seconds (refresh page)
User avatar
lovebug
Posts: 182
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

this one is kind of working ? i think my brain has shut down :?
ladybug.ssd
(9.25 KiB) Downloaded 10 times
screenshot.png
ImageImage
Experimental random joke every 60 seconds (refresh page)
User avatar
Arcadian
Site Admin
Posts: 4023
Joined: Fri Nov 24, 2000 12:16 pm
Contact:

Re: Lady Bug

Post by Arcadian »

Looking really promising now, quite a few sprites on screen and the movement is nice and nippy!
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk
User avatar
tricky
Posts: 5411
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Lady Bug

Post by tricky »

You might want to do what Pac Man does and have each one have its own logic (or you might not really "want" to :lol: ).
Maybe have one "aim" ahead of ladybug and one maybe take the nearest interesting square to ladybug as a target.
You could also have one aim to the opposite side of ladybug to where another specific enemy is.
I put these and a couple more into Rally-X, it didn't make them "clever", but they do seem to be more effective as a whole.
User avatar
lovebug
Posts: 182
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

thanks guys

I had thought of using pacman type aiming as I already have the disassembled and documented code

I keep watching the original arcade ladybug game hoping to understand how its aiming works but I still havent worked it out ! XD

the game can actually handle quite a few sprites but the more you add the lower the frame rate
theres a variable that defines how many sprites in the game, a memory buffer is automatically allocated for them in zeropage with a for next loop
spritesListNum = 5 ; just change this value, everything else is automatic

i think around 15 sprites is the safe limit before the program starts slowing down
the moveSprites function handles adjusting the sprites x y , checking if a sprite is at a junction and direction to turn
it has to parse the whole list every frame so after around 15 sprites it takes too long and slows the game down

this is a build with 10 sprites
ladybug.ssd
(9.25 KiB) Downloaded 6 times
screenshot.png
 
 
--- edit --- this build I added a little more randomness to the turning, seems to help a bit
Last edited by lovebug on Tue Apr 06, 2021 7:26 pm, edited 1 time in total.
ImageImage
Experimental random joke every 60 seconds (refresh page)
User avatar
lovebug
Posts: 182
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

ive tweaked the randomness factor to 33%

when an enemy bug gets to a grid position that has at least 3 paths leading in different directions then its a valid junction, it then has a 33% chance of turning randomly and a 67% chance of turning in the players direction. if the turn in the players direction is blocked by a wall then a random direction is chosen instead

if the grid position has less than 3 paths then nothing is changed and it continues in the direction it was traveling

when an enemy hits a wall it will always choose a random direction unless it happens to be at a valid junction in which case the above rules apply

seems usable
ladybug.ssd
(9.25 KiB) Downloaded 8 times
Last edited by lovebug on Mon Apr 05, 2021 8:28 pm, edited 5 times in total.
ImageImage
Experimental random joke every 60 seconds (refresh page)
User avatar
lovebug
Posts: 182
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

the source (its a bit messy and not optimized, i'll clean it up nearer the end)
ladybug.zip
(43.25 KiB) Downloaded 5 times
ImageImage
Experimental random joke every 60 seconds (refresh page)
User avatar
lovebug
Posts: 182
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

the code for checking and turning the enemys towards ladybug was checking vertical followed by horizontal so that if ladybug was diagonally away from the enemy the horizonal check being the last test would override the vertical test causing the enemys to zigzag horizontally when they were blocked by a wall and aligned with ladybugs x position so would only travel vertically when the random 33% chance turn told them to do otherwise (something like that)

I have fixed this by choosing the order of the tests randomly so theres a 50% chance of checking horizontal followed by vertical and a 50% chance of the other way around and this seems to give the enemys a much greater chance of getting to where they are aiming.

the enemy movement is now looking remarkably similar to the original arcade game :shock:

gave the enemys a bit of color, i'll have to work on some enemy sprites

heh this is almost starting to look like a game :lol:

ladybug.ssd
(9.75 KiB) Downloaded 5 times
hiding in a couple of places to see if the AI can find ladybug. sorry for the first 55 seconds, recorded this for a friend who has never heard of a bbc computer before to give them some idea of the machine

screenshot.png
ImageImage
Experimental random joke every 60 seconds (refresh page)
User avatar
lovebug
Posts: 182
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

had to rewrite the ai code, it was a mess of things I had tried

a lot smaller now, seems to work the same
ladybug.ssd
(9.75 KiB) Downloaded 9 times

Code: Select all

;-----------------------------------------------------------------------------------------------------------------------------------------------------
; moveSprites					update coordinates of all sprites
;-----------------------------------------------------------------------------------------------------------------------------------------------------
; entry			none
;-----------------------------------------------------------------------------------------------------------------------------------------------------
; workspace		moveSpritesIndex	index to current sprite
;			moveSpritesPathCounter	count the number of paths from sprite location to check for valid junction
;
;			moveSpritesSaveDirection
;						temporary storage for sprite direction
;-----------------------------------------------------------------------------------------------------------------------------------------------------
; exit			A			destroyed
;			X			destroyed
;			Y			destroyed
;-----------------------------------------------------------------------------------------------------------------------------------------------------

moveSpritesRandomness	= 33			; 33% chance of picking a random turn
moveSpritesJunctionPaths= 3			; must be at least this number of paths at a grid location to be valid junction

;-----------------------------------------------------------------------------------------------------------------------------------------------------

.moveSprites

if debugRaster					; if debug then set background color

	lda #palGreen
	sta ulaPalette

endif

	lda #spritesListNum - 1			; start at hightest sprite
	sta moveSpritesIndex

.moveSpritesLoop

	ldx moveSpritesIndex			; get current sprite index
	ldy spritesDir, x			; get sprite direction

	lda moveLadybugDirX, y			; choose ladybug or enemy direction X
	cpx #0
	beq moveSpritesLoopDirX
	lda moveEnemyDirX, y

.moveSpritesLoopDirX

	clc					; add direction sprite X
	adc spritesX, x
	sta spritesX, x

	lda moveLadybugDirY, y			; choose ladybug or enemy direction Y
	cpx #0
	beq moveSpritesLoopDirY
	lda moveEnemyDirY, y
	
.moveSpritesLoopDirY
	
	clc					; add sprite DirY to sprite Y
	adc spritesY, x
	sta spritesY, x
	
	lda spritesX, x				; if sprite is not grid aligned the skip it and move onto next sprite
	sta spriteToMapX
	and #&0f
	cmp #&08
	bne moveSpritesNext
	
	lda spritesY, x
	sta spriteToMapY
	and #&0f
	cmp #&08
	bne moveSpritesNext
	
	jsr spriteToMap				; else convert sprite XY to tileMapAddr

	lda #moveSpritesJunctionPaths - 1	; set the number of paths for a valid junction
	sta moveSpritesPathCounter
	
	ldx #3					; count the number of paths
	
.moveSpritesCountPaths

	ldy moveDirMap, x
	lda (tileMapAddr), y
	bmi moveSpritesCountPathsNext
	dec moveSpritesPathCounter

.moveSpritesCountPathsNext
	
	dex
	bpl moveSpritesCountPaths

	ldx moveSpritesIndex			; get current sprite index
	ldy spritesDir, x			; get current direction

	bit moveSpritesPathCounter		; if not a valid junction (not enough paths)
	bpl moveSpritesFindPath			; then go check current direction is a path

.moveSpritesRandomOrAttack

	jsr random				; if random < randomness then pick a random direction
	cmp #(moveSpritesRandomness * 256) / 100
	bcs moveSpritesAttack
	
.moveSpritesRandom

	jsr random
	and #&03
	tay

	bpl moveSpritesFindPath			; go check if this direction is a path
	
.moveSpritesAttack

	jsr random				; choose random order for up/down or left/right attack direction
	bmi moveSpritesUpDownRightLeft

	jsr moveSpritesCheckRightLeft
	jsr moveSpritesCheckUpDown
	jmp moveSpritesFindPath
	
.moveSpritesUpDownRightLeft

	jsr moveSpritesCheckUpDown
	jsr moveSpritesCheckRightLeft

.moveSpritesFindPath

	sty moveSpritesSaveDirection		; save current direction
	
	lda moveDirMap, y			; get direction offset for tile map

	tay					; if tileMap is a wall then try again
	lda (tileMapAddr), y
	bmi moveSpritesRandom

	lda moveSpritesSaveDirection		; get saved direction
	sta spritesDir, x			; set sprite direction

.moveSpritesNext

	dec moveSpritesIndex			; repeat until all sprites updated
	bmi moveSpritesExit

	jmp moveSpritesLoop

.moveSpritesExit

if debugRaster					; if debug then set background color

	lda #palBlack
	sta ulaPalette

endif

	rts					; done.

;-----------------------------------------------------------------------------------------------------------------------------------------------------

.moveSpritesCheckUpDown

	lda spritesY, x
	cmp spritesY
	beq moveSpritesCheckUpDownExit		; if enemyY = ladybugY then return with current direction

	ldy #moveDown				; else choose down or up
	bcc moveSpritesCheckUpDownExit
	ldy #moveUp

.moveSpritesCheckUpDownExit

	rts

;-----------------------------------------------------------------------------------------------------------------------------------------------------

.moveSpritesCheckRightLeft

	lda spritesX, x
	cmp spritesX
	beq moveSpritesCheckRightLeftExit	; if enemyX = ladybugX then return with current direction

	ldy #moveRight				; else choose right or left
	bcc moveSpritesCheckRightLeftExit
	ldy #moveLeft

.moveSpritesCheckRightLeftExit

	rts
ImageImage
Experimental random joke every 60 seconds (refresh page)
User avatar
tricky
Posts: 5411
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Lady Bug

Post by tricky »

Very cool, I like the pragmatic approach to too many enemies. By the time you have enough to notice, you will be far too busy to notice :)
I guess you will get to it, but it would be nice if they didn't ride on each other's backs ;)
User avatar
lovebug
Posts: 182
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

im planning to change the level speed, sprite speed, sprite x/y from 8 to 16 bit using the highest 8 bits of the x/y as the draw position
this will allow the levels to increase the enemy speed gradually instead of from slow to fast to insane :)

having speed start at 0100 for level 1 will move sprites 1 pixel per frame
as the level increases I can add some value to the level speed variable to gradually increase the enemy speed clipping it to some maximum so it doesnt get insanely fast

a quick calculation seems like adding &20 to the speed per round would be good
round 1 = 1.0 pixels / frame
round 2 = 1. 125 pixels / frame
round 3 = 1.25 pixels / frame
round 4 = 1.375 pixels / frame
round 5 = 1.5 pixels / frame
..
..
round 9 = 2.0 pixels / frame

i could store this level speed with slight variations into the sprite list so that each enemy bug is based on the level speed but has a very slight speed difference with the other enemy bugs

this could add something interesting to the game play and will also prevent enemys riding on each others backs for too long :)
ImageImage
Experimental random joke every 60 seconds (refresh page)
User avatar
tricky
Posts: 5411
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Lady Bug

Post by tricky »

Sounds good.
Are you planning on scaling the X and Y speeds to be the same screen inches speed?
I think you might have already said no, but as not everything will now be 1 pixel per frame, it might be worth another look/feel?
User avatar
lovebug
Posts: 182
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

I could go that way but probably wont lol

i might try it, unsure :lol:

well I will try it once of got the code done

omg !
ImageImage
Experimental random joke every 60 seconds (refresh page)
User avatar
lovebug
Posts: 182
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

ive had a very strong feeling of déjà vu during this whole build from the very start, its really strange

like just now when I was thinking about the new 16 bit speed and i'll have to possibly round up the sprite x and y by adding 0.5 (&80) before checking if they are grid aligned and actually grid align them if they test as true to prevent the values skipping over the grid alignment over a long run

I felt like ive dont this before, its most strange

I hope im not having temporal lobe seizures lol
ImageImage
Experimental random joke every 60 seconds (refresh page)
User avatar
Snuggsy187
Posts: 199
Joined: Wed Apr 03, 2019 9:53 pm
Contact:

Re: Lady Bug

Post by Snuggsy187 »

I hope im not having temporal lobe seizures lol
No, that's my trick ! :D

I'll swear blind I haven't heard of something mentioned in a thread for example, and then look back 6 months just to find some comments left by me on the exact same subject ! :shock:

Again, loving reading this topic and your continual daily updates ! :D =D>
DROP PARCHMENT > POKE LOCK > PULL PARCHMENT > CURSE > BARGE DOOR > GO DOOR
User avatar
lovebug
Posts: 182
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

ARGH ! :evil:

I just added 16 bit stuff for fine speed control, it didnt go as planned

I should have just made the direction tables 16 bit and that would have worked but I had to go too far and remove the tables completely, calculate the negative speed from the positive from a new enemySpeed variable and then apply it to either sprite x or y depending on the direction bits :P

and now its a total mess lol
ladybug.ssd
(9.75 KiB) Downloaded 5 times
screenshot.png
ImageImage
Experimental random joke every 60 seconds (refresh page)
User avatar
lovebug
Posts: 182
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

fixed the main issue of the enemys going insane
a couple of places I forgot to add the ",x" so the index addressing was missing and it was constantly reading/writing the same locations corrupting the sprite data

ive tested the enemys with 1.0, 1.125, 1.25 pixel speeds everything is fine but 1.375 or higher they tear through the maze and start wandering around outside

even running at slower than 1 pixel causes the same problems so theres some issue with the rounding and the grid position detect

im pretty bad a math so these sort of issues take me way too long to fix


this build has 1.25 pixel speed for enemys
ladybug.ssd
(9.75 KiB) Downloaded 8 times
screenshot.png
ImageImage
Experimental random joke every 60 seconds (refresh page)
User avatar
lovebug
Posts: 182
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

its so close to working, ive got the game picking a random speed for the enemy bugs from 1.0 to 1.996 pixels per frame

the bugs dont leave the map or drive where they shouldnt do but they can move an extra pixel right or down more than they should (possibly more) which causes the maze walls to partially erase :(

I do have a grid lock in place to remove the fraction and round the sprite x and y to the nearest 8 pixels, might be making them jerky as they approach a grid position

i honestly cant think of a way to fix these issues, ive probably tried 20 different ways of doing this and thew out all the code

when the sprite x/y were integers and the speed was 1,2,4,8 everything was so simple, just or subtract the speed from x or y and test if (x & 15) == 8 && (y & 15) == 8 its grid aligned and time to change direction

now that everything is effectively floating point a simple test for == 8 fails

currently im testing like this

if (x & 15) >= 8 && (x & 15) < 8 + int(speed) + 1 && same for y then its a grid position. its not perfect

I hate math ! im very bad at it
 
ladybug.ssd
(9.75 KiB) Downloaded 4 times
ImageImage
Experimental random joke every 60 seconds (refresh page)
User avatar
tricky
Posts: 5411
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Lady Bug

Post by tricky »

In my Pac Man, I add a speed and when it crosses a threshold, move, for Rally-X, it can cross the threshold twice, meaning that they move 1 pixel twice - simple maths, slight complication on code!.

Pacman does this check to see if the ghosts should move this frame (max 100%)

Code: Select all

lda speed_percentage : clc : adc move : sta move : bcc no_move : sbc #100 : sta move
;; move
.no_move
Rally-X does the same but moves and then uses the same mechanism to see if it should do two moves (min 1 move per frame).
Rally-X doesn't use a percentage, it just adds and moves when C=1, so doesn't bother subtracting.

If you have to go from < 1 per frame to > 1 per frame, you could do the first check for the first move and then check for +ve move and do a second move and subtract if it is.
You would need to scale down the "speed" to make sure that it didn't go past 128 and become negative.
e.g. 50 is once per frame, so when move is +ve, move and subtract 50, add speed once and then check twice.
User avatar
lovebug
Posts: 182
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

Omg tricky your right why didn't I think of that

I changed everything to 16 bit which was totally wrong and gave myself a big headache in the process

Keeping every thing as it was and just having a counter for the fraction calling the move function is the way to do it

Thanks. I'm just in hospital right now getting some xrays and blood tests but as soon as they let me go I'm gonna try this

Thanks ever so much😊
ImageImage
Experimental random joke every 60 seconds (refresh page)
User avatar
tricky
Posts: 5411
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Lady Bug

Post by tricky »

Don't thank me yet ;)
It's only really a different way of thinking about fractions and actually came from stepping in line drawing! There it is the accumulated error and when it gets big enough, you move to the next X or Y and subtract the amount you have moved, as you are now on the other side of the perfect line.
User avatar
lovebug
Posts: 182
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

ive actually written line drawing for the 6809 cpu in the past for controlling an x and y dac for laser control to draw pretty pictures in the sky using exactly this technique

somehow ive forgotten everything over the years :P
Last edited by lovebug on Fri Apr 09, 2021 1:41 am, edited 1 time in total.
ImageImage
Experimental random joke every 60 seconds (refresh page)
User avatar
lovebug
Posts: 182
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

I put everything back to integer

then call the routine to move 1 pixel
do the fraction counter and call move again if theres a carry

still picking a random speed from 00 (1.0 pixels/frame) to ff (1.996 pixels/frame)
i think this range will be enough for the game. anything faster than 2 pixels/frame is crazy :lol:

works perfectly thanks
 
 
ImageImage
Experimental random joke every 60 seconds (refresh page)
User avatar
lovebug
Posts: 182
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

I've done some manual speed tests and its all great, I was thinking I could easily add a difficulty setting on the main screen EASY, NORMAL, HARD which changes the value added to enemySpeed every round


heres the latest build with the random speed every boot.
ladybug.ssd
(9.75 KiB) Downloaded 10 times
screenshot.png
ImageImage
Experimental random joke every 60 seconds (refresh page)
User avatar
lovebug
Posts: 182
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

heh I was just thinking about the good old days when I wrote that 6809 line drawing function to control the x and y digital to analogue converters connected to the two mirror galvanometers directing the beam of the liquid nitrogen cooled 10KW white laser to draw pretty pictures onto the clouds in the sky

the thing was huge, the power supply had cables to the laser about 3 inches in diameter and the laser was about 3.5 metres long :)

i must have been nuts !, i would never go anywhere near something like that these days lol
Last edited by lovebug on Fri Apr 09, 2021 3:19 pm, edited 1 time in total.
ImageImage
Experimental random joke every 60 seconds (refresh page)
Post Reply

Return to “new projects in development: games”