News:

Function Finder  Find all the functions within source code files

Main Menu

Strategy Game - Work In Progress

Started by jimwon, November 09, 2009, 02:45:52 PM

Previous topic - Next topic

jimwon

Had some sort of fugue over the last 14 hours and written this thing which is sort of halfway through a simple strategy/skirmish simulator in a medieval setting - it will be turn based affair and at the moment runs well up to the point where you would push "End This Turn" and the computer would have it's turn.
So, run it up and select 'New Game' with return, then select your units with up/down and right/left to add/subtract units, you will need to select 99 points worth before hitting return to continue. A random playfield is created and then populated with the computer controlled units on the right hand side of the map.
In the main engine, -/+ will zoom in/out the main map, a/z scrolls through your list of units, cursor keys scrolls the map and holding m will pop up a mini map. You start with no units in the field, click on the square in the list and your arrow will turn into a crosshair, click on the map to drop your unit - you will need to deploy on the left hand side on the map.
Left click a unit to select it (this will zoom the map in and might not be centered on your unit - working on that) and it will turn purple and show you where it can move to (green squares) or if it is near enough a enemy unit you will be able to attack it, enemy unit will outline in blue. Your units can move once and attack once per turn. Right click anywhere to de-select a unit.

Seems to run slowly sometimes, so I think it needs a bit of optimisation, any pointers would be welcome, or indeed, any comments. Feel free to nick any bits of code you might want, sorry it's not commented - I know it's a dreadful habit!

jimwon

Tidied some bits and pieces up on this today, added sliders (although they are not intended to be grabbed by the mouse) for the map and the unit list. Found that drawing the little boxes next to each unit on the list was slowing down the program for some reason, so got rid of those and you now select units in the list just by clicking on them. Also added something to slow down user input as I found mouse commands were running into each other despite trying to use FlushMouse, Wait and WaitNoInput commands - so now when you do something your cursor turns into a little clock.

Added a AI routine to move the computer controlled units, but they only try to get to close to your units they don't attack yet. You can add, move and attack CPU units, click on the End Turn button for the the computer to move.

Everything that happens in game is now logged to plog.dat file in the data folder.

What's left to do - AI routine for CPU to attack your units, Saving and Loading procedures, prettification of the start and unit select screens, game resolution and decision on whether to add a series of levels of just set it up as repeating random battles?

jimwon

With some help from Kevin, I've changed the way you and the CPU move on the grid from 4-way movement to any space around a unit within the units move value - looks like a diamond shape in open terrain. I really wanted to implement A Star or some other type of pathfinding to double check all points were viable, but I've had to settle for a really simple routine that checks a few conditions. It's a shame there isn't a decent pathfinding example in basic available, I read all the theory and understood the approach, but I had no idea how to model it - found loads of C#, C++ and Java examples, but that's gobbledegook to me. There's a Playbasic one available, but it's based on hexes and I have no idea how to adapt it, as I don't know how hexes work anyhow.

I've also adjusted things so you can select, move and attack with units at any scale, and made slight graphical changes to the main screen.

Whats left to do... play with the cpu movement routine as at the moment it makes a random move, saving & loading games, prettify the menus, and thinking up a decent name for it.