Jump to content
Sign in to follow this  
Nyerguds

Nyer's old school project game

Recommended Posts

I've recently been working on fixing a game I made years ago, for a school project, so I thought it'd be nice to share the final result with you guys.

The game, simply called "Battle Game", is a simple RPG, loosely based on the HeroQuest board game, with a hero whose task is to clear all enemies on each level. You 'throw' two dice to get action points you need for walking and attacking, you get gold and experience from killed enemies, and leveling up gives you level points that can be distributed over skill sets like strength, magic, evasion, accuracy, etc. Between game levels you end up in a shop where you can buy potions, weapons and spells, and where you can repair your armour if it's damaged.

The original assignment asked for the traditional "battle mode switch" when attacking an enemy, but since the assignment also had magic spells with a "range" property, this seemed rather ridiculous.

The result is a game where the level's terrain is a tactical battlefield. Any enemy will consider attacking you if he can see you and has enough action points to both get to you and attack. You can physically run away from enemies during battle, and you can fire spells and duck behind the walls. Be prepared to get chased though. The AI is quite smart.

The game has inbuilt support for three languages: English, Dutch and French (yes, that was part of the assignment). It's written in Java, so if you got Java installed you should be able to run it by double-clicking the .jar file. There's a readme file for each language, and an inbuilt help system in the game's top menus.

Note that there are no visual effects of any kinds for the attacks. Just watch the text box at the bottom for status updates when battling.
 

 

The game:
Download game
Download Source code

(I don't encourage downloading the source code. Not only because it's an old project with messy code, but also because 90% of the function names, comments and internal commands are written in Dutch. In fact, anything English you'd find in there is probably my new updated code)

 

Some screenshots:

battle_game_start.jpg

battle_game_dungeon.png

battle_game_pyramid.jpg

 

Notes:

1. Shortcuts:

I added three handy keyboard shortcuts that actually do a bit more than their GUI equivalents. Normally, to attack enemies, you have to click on them to start a battle, and then use a weapon or spell.

The shortcuts "w" (weapon) and "s" (spell) will do more than just pop up the "use weapon"/"use spell" menu though; if you're not already in a battle, they'll automatically search for enemies around you, attacking the nearest one automatically. If the game gives an error message box, it means you can't attack because there are either no enemies in range of your weapons or spells, or you don't have enough action points or magic points to execute the attack.

This logic makes the game more fluent, since you don't have to switch between the mouse and the keyboard all the time. Some functions, like drinking potions, still require clicking on buttons on the GUI though.

The space bar acts as shortcut for the "end turn" button. Note that in the original game, ending turns while walking was a tedious business, since you constantly used up your action points doing nothing but walking. I now automated this by making the game end your turn automatically when you are in no danger of getting attacked by nearby enemies. You can still force the game to end your turn and re-roll your action points by pressing space bar (or the GUI button), which can be handy to make sure you don't end up in an enemy's line of sight with barely any action points. (re-rolling until you get the full 12 action points and then jumping out in front of an enemy is a sort of "allowed cheat" in the game ;) )

 

2. Making new levels:

Levels are simple text files. You can open any level from the data/levels folder and see how they work. The available monsters can be seen in the data/images/monsters folder. Note that technically, it's possible to put hero types on the map as monsters too, but this is completely untested :P

Since the window adapts to the level's size, level size is basically limited by how big your screen is. Cells are 40x40 pixels, the rest of the math is yours. All of the original levels are made to fit in 1024x768.

To add a level, simply put it in the levels folder (data/levels) with "level##.lvl" as filename (## being the level number). The original game has 9 levels, but you can keep playing until the program doesn't find a level for the next level number.

## Ogre Dungeon

x=15
y=14
terrain=dungeon
wall=*
hero=h
monster=ogre,o
monster=imp,i

[map]
map=***************
map=h    **       *
map=     ** *** * *
map=****o** *** * *
map=*       *   * *
map=* ******* o * *
map=*     ***   *i*
map=***** ******* *
map=*   o      ** *
map=* *   ** *    *
map=* *****  *  ***
map=*  i*    *  ***
map=*****i  ** o  *
map=***************

3. The 'line of sight' logic:

The thing I've been upgrading most is the line of sight logic, which was really buggy in the original. I frequently encountered situations where the enemies could attack me with spells but I couldn't attack them back because I 'didn't see' them, and vice versa, so I rewrote the whole thing from scratch.

Basically, having a line of sight means having a clear path to the enemy. A line of sight means you can start a battle with an enemy, and can attack him with ranged spells. Since you can't move diagonally, you can't fire spells if you don't have the extra cells to do the side-steps, either. Some situations give diagonal lines where these side-steps can be taken in 2 directions; in that situation, the line of sight is only valid if all of these side steps are taken to the same side.

No line of sight:

sight_algorithm_v1.12_1_false.png

Valid line of sight:

sight_algorithm_v1.12_2_true.png

Special case: a pure diagonal line exists, but the side steps don't make a valid line, since the 2 corners each block off half of the 'sight':

sight_algorithm_v1.12_3_diagonal_attacks

Share this post


Link to post

No love for more simple games? :(

Share this post


Link to post

Mmmmm... maybe not enough enemies. You might want to download Desktop Dungeons and examine it a bit.

Share this post


Link to post

Not enough? What do you mean? Not enough per level, or not enough variety? At this moment, the game is mostly built up to show one new enemy on each level, and then combine a bunch of them in the last level. But as I said, levels can easily be replaced. If you want to make a different/rebalanced level set for it, go right ahead.

There's still an unused enemy in there too, btw... the Skeleton. I made all of its stats but never got around to putting it in a level. And then there's the fact you can technically put the hero characters on the map as enemies too.

 

Adding enemies and levels is incredibly easy anyway. All you need to add/edit enemies is a tool to edit SQLite database files, like SQLite Browser (and a new image, if you're adding new ones), and as I explained already, levels are simple text files.

Still, with the current levels, I think you need to balance your spending and level points pretty wisely to beat the 'Hell Arena' level with all the demons. Those guys are scary.

 

 

As I said though, this is an old game, so I'm probably not going to spend more time tweaking the actual code.

Share this post


Link to post
Not enough per level, or not enough variety?

Both actually. I just might play this to examine it fully, but so far this really reminds me of Desktop Dungeons.

Share this post


Link to post

Well, I just updated the rar file; there was an error in the last level that made it crash the game. I should really build in some dummy graphics in case it can't find stuff :P

 

If you already got a save game, it's better to just copy the data/levels folder though. The data/gevechtsspel.db file contains all monster/hero/weapons/etc stats, AND the save games. Kind of a messy storage system, but meh, I'm not changing it.

Share this post


Link to post

i like it Nyerguds it is a good little time waster, dont know about the earthquake attack, as i might jinx christchurch (where i live) again.

 

just love it. it will stay on my HDD

Share this post


Link to post
Guest Stevie_K

That's awesome!

So I'm not the only amateur game developer here after all! :P

 

It could use some graphical improvements though.

Share this post


Link to post
i like it Nyerguds it is a good little time waster, dont know about the earthquake attack, as i might jinx christchurch (where i live) again.

lol. Earthquake is actually one of the most useful spells in the game, imo. I end up using it a lot against heavy enemies, like the Demons. It has relatively low cost and high damage, but in exchange you have to be quite close to the enemy.

 

just love it. it will stay on my HDD

heh, thanks :)

 

That's awesome!

So I'm not the only amateur game developer here after all! :P

 

It could use some graphical improvements though.

Well, it was just a school project, after all. Though personally, the improvements I'd still add are stuff like the ability to check if you can see an enemy, and requesting the list of the current spells you got without needing to attack an enemy for it (like, in the shop).

Share this post


Link to post

Game updated, and rar pack uploaded. If you got savegames, make sure you don't overwrite the "data/gevechtsspel.db" file when updating.

 

1. The mouse-over information on enemies will now show whether they're visible or not.

2. AI update: Enemies that come towards you will take one less step if they can attack diagonally.

 

Original behaviour:

ai_improvement_1_normalpath.png

 

New improved behaviour:

(this gives the enemy one more action point to attack you with)

ai_improvement_2_efficientpath.png

 

This obviously doesn't affect the visibility check in any way. The path optimization happens after that's already done.

Share this post


Link to post

It was fun to work on it again :)

Share this post


Link to post

Just added a silly little extra... holding down [ctrl] gives a visual display of the visibility checker algorithm. [ctrl] shows it to the first obstruction, [ctrl]+[shift] shows the full path :P

 

I call it the "flashlight" :3

path_display_v1.14.png

note: pic is shooped; in reality the info label is not shown in flashlight mode, since it'd get in the way. I just added it because none of the other screenshots show the new 2-line info label.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×