News:

Welcome to RetroCoders Community

Main Menu

CoinHunt!

Started by ZXDunny, Jun 06, 2023, 04:03 PM

Previous topic - Next topic

ZXDunny

As promised, here's links to the sources and a compiled executable of the SpecBAS version of CoinHunt.

Enhancements are:

1. Smooth movement due to no console window
2. The monsters will "lock on" to you if you get too close to them
3. The monsters gradually get faster as the levels progress
4. The monsters may decide to group around a coin to protect it

Tbh, it may be a little hard as I can only get to level four. Herding monsters is a thing and can help with the last coin or two. Diagonal movement is much faster than the regular directions.

The executable runs in fullscreen and at half your desktop resolution, with keys WASD to move.

https://drive.google.com/file/d/1V1ISHIfe4WsMO2CCcClW3AuKWIeymEGj/view?usp=sharing

The source is here:

https://github.com/ZXDunny/SpecBAS-Demos/blob/master/Games/coinhunt

It's not a compact nightmare this time, I've tried to make it a little easier to read.

Have fun, and report any problems here - I'm sure there will be some.

ZXDunny

What spec is your PC and GPU? And what desktop resolution are you running at? I developed this at 1920x1080 desktop. What you could do is replace line 10 with just

10 PAPER 0: INK 14: CLS

To avoid the full-screen stuff that your PC is probably having trouble with.

ZXDunny

Line 370 moves the monsters. The array is monsters(count,5), so:

monsters(n,1) is the x coord of the monster
monsters(n,2) similarly is the y coord of the monster.
monsters(n,3) is the monster's destination X coordinate.
monsters(n,4) is the monster's destination Y coordinate.
monsters(n,5) is 0 if the monster is patrolling, 6 if it's chasing the player.

Line 370 gets the distance of the monster from its destination. That may be the player, or a point on the screen. It also gets the distance (using the PYTH function to get the hypotenuse of the triangle the monster and player form) to the player. If the player is within 50 pixels, the monster sets the player as it's new destination. Otherwise it continues to check:

If the destination is within 7 pixels, it jumps to line 400 to choose a new destination. If it's further away, then it gets the angle - a=POLAR(dx,dy) - and then moves the monster by using that value in a couple of trig functions to get the direction of travel.

Line 400 first checks (pdist<7) that we're not touching the player, and then if not, chooses a new destination for the monster. If we're on level 1, it will always be a random point somewhere inside the circle 32 pixels radius from the monster. If we're on level 2 and up, it can choose, randomly, a point around a coin to guard. (this fun little addition means that as you get all the coins, the monsters tend to flock to the last few, making it harder).

And that's about it!

ZXDunny

Quote from: aurel on Jun 15, 2023, 11:43 AMyour program for specBas is more complex than FB

Yes, moving pixel-by-pixel instead of using characters, adding monster destination targets, animated coins and monsters that chase the player when they're close to them tends to add some code to the original :D