@Virtual Nomad
Thanks for the support.
@Ashingda 27
Alright, awesome go for it. Try to make an AI system using these UDTs (posted below in code), if you need to modify them just let us know. Try to make the system as modular as possible so that we only need to call a few functions from within the main loop. Post them here when you get them working, if that's alright.
@lucifer 1101
I'm going to assume that we are building off your menu code, since you were the originator of the project. So I will maintain the updated version of our main project file and start working on these functions:
SpawnEnemy( ... )
SpawnEnemyProjectile( ... )
ControlEnemyProjectiles( ... )
ControlPlayers( ... )
If you would work on the Menu and the Graphical User Interface(GUI) that would be top notch.
EDIT: goram typos...
I will post the code again when things are more fully functional, but here is the complete source code I have so far:
sync rate 60
sync on
set display mode 640,480,32
gosub SetupVariables
gosub SetupMenu
` Begin the main loop
do
` if the menu is active
if Menu=1
gosub HandleMenu
Endif
if playing=1
gosub HandleBG
gosub HandleEnemies
gosub HandlePlayer
endif
sync
loop
`--------------------------------------- Subroutines ----------------------------------------------
SetupVariables:
` Define UDTs
type Projectile
X# as float
Y# as float
Angle# as float
Speed# as float
TrajectoryID as integer
ImageID as integer
SpriteID as integer
Damage as integer
Life as integer
LifeTime as integer
endtype
type Plane
X# as float
Y# as float
Angle# as float
Speed# as float
ImageID as integer
Across as integer
Down as integer
AnimIndex as integer
WeaponType as integer
Health as integer
MaxHP as integer
endtype
type Player
Plane as Plane
keyLeft as integer
keyRight as integer
keyUp as integer
keyDown as integer
keyFire as integer
keyBomb as integer
endtype
` Trajectory Constants
#constant TRJ_STRIAGHT_SHOT 1 ` The shot fires and continues on a straight path until death.
#constant TRJ_LASER_BEAM 2 ` The shot fires in a straight line instant damage.
` Weapon Constants
#constant WPN_7_62MM_CANNON 1 ` Fires rapid straight shot with 10 damage points / shot.
` Declare game variables
global dim EnemyProjectiles(0) as Projectile
global dim PlayerProjectiles(0) as Projectile
global dim Enemies(0) as Plane
global dim Players(0) as Player
return
SetupMenu:
` Menu variables - may need to make them global for use in functions, or make them local to the function
` or pass them in as parameters. -Pillarofire.
Menu=1
ClickIndex=0
MBX=76
MBY=20
MBSplit=40
MBDown=410
` Load the media for the menu
` Check for a save file
return
HandleMenu:
` Show the main menu
` Display the title screen
` Play BG Music
` Draw each of the Menu options with mouse over and click option
` Continue
if mousex() > MBSplit
if mousex() < MBSplit+MBX
if mousey() > MBDown
if mousey() < MBDown+MBY
ink RGB(0,0,255),0
if mouseclick()
gosub LoadSaveandContinue
endif
else
ink RGB(255,255,255),0
endif
else
ink RGB(255,255,255),0
endif
else
ink RGB(255,255,255),0
endif
else
ink RGB(255,255,255),0
endif
box MBSplit,MBDown,MBSplit+MBX,MBDown+MBY
ink rgb(0,0,0),0
text MBSplit+4,MBDown,"Continue"
` New Game
if mousex() > MBSplit*2+MBX
if mousex() < MBSplit*2+MBX*2
if mousey() > MBDown
if mousey() < MBDown+MBY
ink RGB(0,0,255),0
if mouseclick()
gosub SetupNewGame
endif
else
ink RGB(255,255,255),0
endif
else
ink RGB(255,255,255),0
endif
else
ink RGB(255,255,255),0
endif
else
ink RGB(255,255,255),0
endif
box MBSplit*2+MBX,MBDown,MBSplit*2+MBX*2,MBDown+MBY
ink rgb(0,0,0),0
text MBSplit*2+MBX+6,MBDown,"New Game"
` Otions
if mousex() > MBSplit*3+MBX*2
if mousex() < MBSplit*3+MBX*3
if mousey() > MBDown
if mousey() < MBDown+MBY
ink RGB(0,0,255),0
if mouseclick()
gosub OptionsMenu
endif
else
ink RGB(255,255,255),0
endif
else
ink RGB(255,255,255),0
endif
else
ink RGB(255,255,255),0
endif
else
ink RGB(255,255,255),0
endif
box MBSplit*3+MBX*2,MBDown,MBSplit*3+MBX*3,MBDown+MBY
ink rgb(0,0,0),0
text MBSplit*3+MBX*2+9,MBDown,"Options"
` Credits
if mousex() > MBSplit*4+MBX*3
if mousex() < MBSplit*4+MBX*4
if mousey() > MBDown
if mousey() < MBDown+MBY
ink RGB(0,0,255),0
if mouseclick()
gosub CreditsMenu
endif
else
ink RGB(255,255,255),0
endif
else
ink RGB(255,255,255),0
endif
else
ink RGB(255,255,255),0
endif
else
ink RGB(255,255,255),0
endif
box MBSplit*4+MBX*3,MBDown,MBSplit*4+MBX*4,MBDown+MBY
ink rgb(0,0,0),0
text MBSplit*4+MBX*3+10,MBDown,"Credits"
` Quit
if mousex() > MBSplit*5+MBX*4
if mousex() < MBSplit*5+MBX*5
if mousey() > MBDown
if mousey() < MBDown+MBY
ink RGB(0,0,255),0
if mouseclick()
end
endif
else
ink RGB(255,255,255),0
endif
else
ink RGB(255,255,255),0
endif
else
ink RGB(255,255,255),0
endif
else
ink RGB(255,255,255),0
endif
box MBSplit*5+MBX*4,MBDown,MBSplit*5+MBX*5,MBDown+MBY
ink rgb(0,0,0),0
text MBSplit*5+MBX*4+23,MBDown,"Quit"
return
LoadSaveandContinue:
Menu=0
cls
text 10,10,"No Save File Found"
` Load the save file
` Load the Game Media
` Initialize the game data
return
SetupNewGame:
Menu=0
cls
text 10,10,"New Game"
` Load the Game Media
` Initialize the game data
return
OptionsMenu:
` Load the Options
return
CreditsMenu:
` Display the Credits
return
HandleBG:
` Control the Background first
` Get the portion of the background that we are currently at and draw it to the screen
` Increment our position and check if we are approaching the next sector.
` if we are approaching the next sector then load that sector and prepare its enemies
return
HandleEnemies:
` Control the Enemies
` Spawn new enemies
` Control Enemy projectiles
` Spawn new Projectiles
` Update spawned projectiles and destroy if old
` if collision with player occurs
` play explosion sound
` reduce health of player
` Update spawned enemies positions and kill if health < 0
return
HandlePlayer:
` Control the Player
` Get Player input
` If player wants to quit then return to main menu
` Update player and check if health is below min, destroy if necessary and play explosion
` Control Player projectiles
` Spawn new Projectiles
` Play spawn projectile sound
` Update spawned projectiles and destroy if old
` if collision with player occurs
` reduce health of player
` show impact animation?
` If destroyed and lives = 0 then end game and return to main menu
return
`--------------------------------------- Functions ----------------------------------------------
function SpawnEnemy( x#, y#, angle#, weaponType )
array insert at bottom Enemies(0)
Enemies().X# = x#
Enemies().y# = y#
Enemies().Angle# = angle#
Enemies().WeaponType = weaponType
endfunction
function SpawnEnemyProjectile( x#, y#, angle#, damage, image, trajectoryType )
array insert at bottom EnemyProjectiles(0)
EnemyProjectiles().X# = x#
EnemyProjectiles().Y# = y#
EnemyProjectiles().Angle# = angle#
EnemyProjectiles().Damage = damage
EnemyProjectiles().ImageID = image
EnemyProjectiles().TrajectoryID = trajectoryType
endfunction
function ControlEnemyProjectiles()
Limit = array count( EnemyProjectiles(0) )
for id = 1 to Limit
` Update the coordinates
select EnemyProjectiles().TrajectoryID
case TRJ_STRIAGHT_SHOT
` Straight shot code...
endcase
case default
` TrajectoryID doesn't exist/ isn't defined.
endcase
endselect
` Check collision
PlayerID = CheckEnemyProjectileCollision( id )
` Deal Damage
if PlayerID > 0
Players(PlayerID).Plane.Health = Players(PlayerID).Plane.Health - EnemyProjectiles().Damage
endif
` Draw it or delete it.
```` You get the idea....
next id
endfunction