TGC Codebase Backup



Basic Battle Engine by Zero Blitzt

27th Mar 2004 9:20
Summary

A basic battle engine for fighting games.



Description

The short description says it all. Parts of this you will have to code yourself, because the code may vary from game to game.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    sync on : sync rate 25 : backdrop off
`Thus begins my first battle engine...

Gosub _types
Gosub _setup

yourturn=1
enemyturn=0
attack=1


do
cls
Gosub _stats

If spacekey()=1 AND attack=1 THEN gosub _attack
IF yourturn=1 : Text 200,400,"Your Turn" : enemyturn=0 : Endif
IF enemyturn=1 : Text 200,400,"Enemy's Turn" : yourturn=0 : Endif
IF attack=0 THEN gosub _enemyattack

sync
loop

_types:

`Main Character
Type MainChar
Name as string
Health as integer
Level as integer
Endtype

Char as MainChar
Char.Name=charname$
Char.Health=100
Char.Level=1

`Enemys

Type MainEnemy
Health as integer
Level as integer
Endtype

Enemy as MainEnemy
Enemy.Health=75
Enemy.Level=1
return

_setup:
Text 500,1,"GX Battle Engine"
sync
Input "What is your character's name>",charname$
sync
return

_stats:
Set cursor 0,30 : Print charname$;" Health: ";Char.Health;"!":
Set cursor 0,40 : Print "Enemy Health is ";Enemy.Health;"":
Set cursor 0,50 : Print "Your level is ";Char.Level;" and the enemy's is ";enemy.level;".": sync
sync
return

_attack:
`This is where you put in your battle system, I just made a basic one.
Enemy.Health=Enemy.Health-1
yourturn=0 : enemyturn=1 : attack=0

return

_enemyattack:
`Also include an enemy battle system. This is another basic one.
`You may want to include a defend system also.
Char.Health=Char.Health-1
IF Enemy.Health=0 THEN Text 200,500,"Enemy Defeated!"
yourturn=1 : enemyturn=0 : attack=1
return