Lol Hoping that all of you are on 56k and could not find the time to download my engine I decided to post the code for you.
Note: Just save the code below in individual files. I would however recommend you download my engine with the link above because it comes with images.
Below is the Main game code. As you can see its much nicer then my old version in the codebase and my other thread. Name this file whatever you want.
` This is a 2d Shoot Em Up engine by Stephen Sokolowski AKA Skeletor
` Use this as a Basis to make your own Shoot em up games
` To Start your Game, Enter the Name of it In the Title Screen
sync on
sync rate 60
hide mouse
`Title Screen
hide mouse
set text font "times new roman"
set text size 20
center text 320,0,"Enter Game Title Here"
set text size 20
`Please keep the following line in your game!!
center text 320,80, "Made By: 2d Shoot Em Up Engine"
set text size 20
center text 320,125, "Enter Game Description"
center text 320,145, "Add more to Game Description if needed"
set text size 20
center text 320,190,"CONTROLS:"
set text size 20
center text 320,230, "Space Bar : Fires guns"
center text 320,260, "UpKey : Reloads guns"
center text 320,290, "Leftkey : Strafes player left"
center text 320,320, "Rightkey : Strafes player right"
set text size 20
center text 320,390, "PRESS ANY KEY TO CONTINUE"
wait key
cls
RANDOMIZE TIMER()
dim Lifes(0)
dim BossLife(0)
dim PlayerX(0)
dim PlayerY(0)
dim BulletX(0)
dim BulletY(0)
dim MoveBoss(0)
dim BossX(0)
dim BossY(0)
dim BossBulletX(0)
dim BossBulletY(0)
LoadMedia()
#Include "LoadMedia.dba"
`NOTE CHANGE THE FOLLOWING CODE IN BETWEEN THE = SIGNS IF YOU WOULD LIKE
`===============================================
`Enemies DIVIDED by EnemyWaves is the Number of Enemies Per Wave
`NOTE: Allow Enemies/EnemyWaves to Divide Evenly... No Decimals!!!!
Enemies = 3
EnemyWaves = 3
`Define how many Lifes the Player will receive for the game
Lifes(0) = 10
`Define how many Ammo Clips the Player will receive for the game
Ammo = 3
`Controls the Speed for the Players Bullet
BulletSpeed = 10
`Number Of Lifes the Boss Enemy Has
BossLife(0) = 6
`Speed at which the Boss's Bullet will be moving
BossBulletSpeed = 8
`Speed at which the Boss will be moving side to side
BossSpeed = 2.5
`Speed the first wave of enemies move at
EnemySpeed = 2
`Speed the first wave of enemies Bullets will move at
EnemyBulletSpeed = 7
`Position of the Shield/Barrier
ShieldX = 280
ShieldY = 350
`================================================
`==========================================================
`Change These varibles so Your Bullet sprite comes out of
`Your Player/Enemy/Boss's sprites Guns
`If you do not change these your bullet make come out of
`Your Images body or arm
`==========================================================
BulletOutOfGunX = 40
BulletOutOfGunY = 405
BossBulletOutOfGunX = 45
BossBulletOutOfGunY = 45
EnemyBulletOutOfGunX = 20
EnemyBulletOutofGunY = 55
`==========================================================
set text opaque
set text size 20
`Enter Your Game Title Here
`---------------------------------
text 25,1, "Enter Game Title Here"
`---------------------------------
text 480,1, "Player Lifes: "
text 280,1, "Ammo Clips: 3"
`Coordinates for player
PlayerX(0) = 300
PlayerY(0) = 400
Bullets = 76
`Comes Out of Gun (Adjust to match your Player Sprites Gun)
BulletX = PlayerX + BulletOutOfGunX
BulletY = BulletOutOfGunY
MoveBoss(0) = rnd(1)
BossX(0) = rnd(500)
BossY(0) = rnd(200)
BossBulletX(0) = BossX + BossBulletOutOfGunX
BossBulletY(0) = BossY + BossBulletOutOfGunY
NPerWave = Enemies / EnemyWaves
dim Wave(EnemyWaves + 1)
NumOfLifes = Lifes(0)
dim Firing(0)
Firing(0) = 0
`Position our first Wave of Enemys
`Create an Array for the Enemies X coordinates
dim EnemyX(Enemies)
for EX = 1 to Enemies
EnemyX(EX) = rnd(500)
next EX
`Create an Array for the Enemies Y coordinates
dim EnemyY(Enemies)
for EY = 1 to Enemies
EnemyY(EY) = rnd(200)
next EY
`Move Enemy sprite
dim MoveEnemy(Enemies)
for ME = 1 to Enemies
MoveEnemy(ME) = rnd(1)
next ME
`Position Bullet to come out of Enemy or Enemy Gun.
`You will have to fix these variables so the Bullets
`Come out of your enemy sprites properly.
Dim EnemyBulletX(Enemies)
for EBX = 1 to Enemies
EnemyBulletX(EBX) = EnemyX(EBX) + EnemyBulletOutOfGunX
next EBX
Dim EnemyBulletY(Enemies)
for EBY = 1 to Enemies
EnemyBulletY(EBY) = EnemyY(EBY) + EnemyBulletOutOfGunY
next EBY
`These next Lines position your Player Life Icons
`===================================================
dim LifeX(NumOfLifes)
dim LifeY(NumOfLifes)
for Life = 1 to NumOfLifes
LifeX(Life) = 440 + L
LifeY(Life) = 20
L = L + 20
next Life
`===================================================
`This Positions the Players Ammo in the top center of the screen
`You shouldnt need to change the values here
dim PosBulletX(20)
for PBX = 1 to 20
PosBulletX(PBX) = 220 + x
x = x + 10
next PBX
dim PosBulletY(20)
for PBY = 1 to 20
PosBulletY(PBY) = 25
next PBY
`-----------------------------------------------------
`-----------------M_A_I_N--L_O_O_P--------------------
`-----------------------------------------------------
do
`The following lines below implement the Controls stated on the
`Title Screen
`Moves the Player to the left
if leftkey() = 1 then playerX(0) = playerX(0) - 3
`Moves the Player to the Right
if rightkey() = 1 then playerX(0) = playerX(0) + 3
`This code is stating that if the Bullets variable is less then 57 and the upkey is pressed
`And The Player Has Ammo left then Reload the Guns and restore the Bullet sprites under Ammo Clips
if bullets < 56 and upkey() = 1 and ammo > 0 then ReloadBullets = 1
`If Spacekey is pressed then fire bullets
if spacekey() = 1 and bullets >= 56 then firing(0) = 1
`This fires the Players Bullet
if firing(0) = 1
BulletY(0) = BulletY(0) - BulletSpeed
endif
`If firing = 0 then Make sure that the players Bullet Follows
`The Player as he moves
if firing(0) = 0
BulletX(0) = PlayerX(0) + BulletOutOfGunX
BulletY(0) = BulletOutOfGunY
endif
`If the Bullet is shot then Delete a Bullet under Ammo clips and
`Play Gun sounds
if bullety(0) <= 390 and BulletY(0) >= 385 then DeleteBullets = 1 : play sound 1
`Player Boundarys
if playerX(0) < 10 then playerX(0) = 11
if playerX(0) > 565 then playerX(0) = 564
`Bullet Boundarys
if BulletY(0) < 50 then firing(0) = 0 : BulletX(0) = playerX(0) + BulletOutOfGunX : BulletY(0) = BulletOutOfGunY
for LifesLeft = 1 to NumOfLifes
if lifes(0) = LifesLeft - 1 then delete sprite Lifes(0) + 80 : LifeX(LifesLeft) = 680 : LifeY(LifesLeft) = 680
next LifesLeft
if Lifes(0) = 0 then text 290,240,"Game Over!" : wait 1000 : end
sprite 3,BulletX(0),BulletY(0),3
sprite 1,playerX(0),playerY(0),1
sprite 4,ShieldX,ShieldY,6
sprite 56, PosBulletX(1),PosBulletY(1),7
sprite 57, PosBulletX(2),PosBulletY(2),7
sprite 58, PosBulletX(3),PosBulletY(3),7
sprite 59, PosBulletX(4),PosBulletY(4),7
sprite 60, PosBulletX(5),PosBulletY(5),7
sprite 61, PosBulletX(6),PosBulletY(6),7
sprite 62, PosBulletX(7),PosBulletY(7),7
sprite 63, PosBulletX(8),PosBulletY(8),7
sprite 64, PosBulletX(9),PosBulletY(9),7
sprite 65, PosBulletX(10),PosBulletY(10),7
sprite 66, PosBulletX(11),PosBulletY(11),7
sprite 67, PosBulletX(12),PosBulletY(12),7
sprite 68, PosBulletX(13),PosBulletY(13),7
sprite 69, PosBulletX(14),PosBulletY(14),7
sprite 70, PosBulletX(15),PosBulletY(15),7
sprite 71, PosBulletX(16),PosBulletY(16),7
sprite 72, PosBulletX(17),PosBulletY(17),7
sprite 73, PosBulletX(18),PosBulletY(18),7
sprite 74, PosBulletX(19),PosBulletY(19),7
sprite 75, PosBulletX(20),PosBulletY(20),7
for LifeSprite = 1 to Lifes(0)
SpriteN = LifeSprite + 79
sprite SpriteN,LifeX(LifeSprite),LifeY(LifeSprite),2
next LifeSprite
`Delete the Bullet sprites under Ammo Clips
if DeleteBullets = 1
bullets = bullets - 1 * 1
for PBU = 55 to 74
BN = PBU - 54
if Bullets = PBU then PosBulletX(BN) = 680 : PosBulletY(BN) = 680
next PBU
deletebullets = 0
endif
if ReloadBullets = 1
bullets = 76
for PBX = 1 to 20
PosBulletX(PBX) = 220 + y
y = y + 10
if PBX = 20 then Y = 0
next PBX
for PBY = 1 to 20
PosBulletY(PBY) = 25
next PBY
Ammo = Ammo - 1 * 1
text 280,1, "Ammo Clips: " + STR$(Ammo)
play sound 2
ReloadBullets = 0
endif
PlayerBulletHitShield(3,4)
`============================================
`=============Begin Enemy Code===============
`============================================
`The Following Lines of code will fire the Enemies Bullets.
for EnemyFire = 1 to Enemies
EnemyBulletY(EnemyFire) = EnemyBulletY(EnemyFire) + EnemyBulletSpeed
next EnemyFire
`Move Enemy
for a = 1 to Enemies
if MoveEnemy(a) = 0 then EnemyX(a) = EnemyX(a) + EnemySpeed
if MoveEnemy(a) = 1 then EnemyX(a) = EnemyX(a) - EnemySpeed
next a
`Enemy Boundarys
for EB = 1 to Enemies
if EnemyX(EB) < 10 then MoveEnemy(EB) = 0
if EnemyX(EB) > 565 then MoveEnemy(EB) = 1
next EB
`Enemy Bullet Boundarys
for EBB = 1 to Enemies
if EnemyBulletY(EBB) > 500
EnemyBulletX(EBB) = EnemyX(EBB) + EnemyBulletOutOfGunX
EnemyBulletY(EBB) = EnemyY(EBB) + EnemyBulletOutOfGunY
endif
next EBB
`============================================
`==========BEGIN FIRT WAVE OF ENEMIES========
`============================================
for EnemyWave1 = 1 to NPerWave
Enemy = EnemyWave1 + 100
EnemyBullet = EnemyWave1 + 600
sprite Enemy,EnemyX(EnemyWave1),EnemyY(EnemyWave1),10
sprite EnemyBullet,EnemyBulletX(EnemyWave1),EnemyBulletY(EnemyWave1),11
next Enemies
for C = 601 to NPerWave + 600
EnemyBulletHitShield(C)
next C
`EnmB = EnemyBullet
for EnmB = 601 to NPerWave + 600
EnemyBulletHitPlayer(EnmB)
next EnmB
`If players Bullet Hits
for PlayerBullet = 101 to NPerWave + 100
PlayerBulletHitEnemy(PlayerBullet,2)
next PlayerBullet
`==============================================
`===========END FIRT WAVE OF ENEMIES===========
`==============================================
`==============================================
`===========Second Wave of Enemies=============
`==============================================
if EnemyWaves > 20 then EnemyWaves = 20
if EnemyWaves1 = 0
for W = 1 to EnemyWaves
WS = W + 1
if Wave(WS) = NPerWave
if W = EnemyWaves then BossBattle = 1 : EnemyWaves1 = 1 : Goto BossBattle
for EnemyWaveN = (NPerWave * W) + 1 to NPerWave * (W + 1)
Enemy = EnemyWaveN + 100
EnemyBullet = EnemyWaveN + 600
sprite Enemy,EnemyX(EnemyWaveN),EnemyY(EnemyWaveN),10
sprite EnemyBullet,EnemyBulletX(EnemyWaveN),EnemyBulletY(EnemyWaveN),11
next EnemyWaveN
EnemyBulletSpeed = 8 + (W * .25)
EnemySpeed = 2.5 + (W * .25)
if W = 1 or W = 3 or W = 5 or W = 7 or W = 9 or W = 11 or W = 13 or W = 15 or W = 17 or W = 19
for PB = NPerWave * W + 101 to NPerWave * (W + 1) + 100
PlayerBulletHitEnemy(PB,W + 2)
next PB
for C = NPerWave * W + 601 to NPerWave* (W + 1) + 600
EnemyBulletHitShield(C)
next C
for EnmB = NPerWave * W + 601 to NPerWave* (W + 1) + 600
EnemyBulletHitPlayer(EnmB)
next EnmB
endif
if W = 2 or W = 4 or W = 6 or W = 8 or W = 10 or W = 12 or W = 14 or W = 16 or W = 18 or W = 20
for PB = NPerWave * W + 1 + 100 to NPerWave * (W + 1) + 100
PlayerBulletHitEnemy(PB,W + 2)
next PB
for C = NPerWave * W + 1 + 600 to NPerWave * (W + 1) + 600
EnemyBulletHitShield(C)
next C
for EnmB = NPerWave * W + 1 + 600 to NPerWave * (W + 1) + 600
EnemyBulletHitPlayer(EnmB)
next EnmB
endif
endif
next EnemyWaves
endif
`==============================================
`==============B_O_S_S__C_O_D_E================
`==============================================
BossBattle:
if BossBattle = 1
sprite 8,BossX(0),BossY(0),8
sprite 9,BossBulletX(0),BossBulletY(0),9
delete sprite 4
shieldX = 2000
shieldY = 2000
`Fire Boss Bullets
BossBulletY(0) = BossBulletY(0) + BossBulletSpeed
`Boss Bullet Boundarys
if BossBulletY(0) > 500 then BossBulletX(0) = BossX(0) + BossBulletOutOfGunX : BossBulletY(0) = BossY(0) + BossBulletOutofGunY
`Move Boss
if MoveBoss(0) = 0 then BossX(0) = BossX(0) + BossSpeed
if MoveBoss(0) = 1 then BossX(0) = BossX(0) - BossSpeed
`Boss Boundarys
if BossX(0) < 10 then MoveBoss(0) = 0
if BossX(0) > 565 then MoveBoss(0) = 1
PlayerBulletHitBoss(8,3)
BossBulletHitPlayer(9,1)
if BossLife(0) < 1
BossX(0) = 2000
BossY(0) = 2000
BossBulletX(0) = 2000
BossBulletY(0) = 2000
`Enter The Following Information that Applies to your game
`-----------------------------------------------------------------
text 200,260, "You Have Defeated BOSS'S NAME and His Army!!"
`-----------------------------------------------------------------
sleep 2000
end
endif
if sprite hit(9,4) = 1
play sound 5
FireBullet = 1
endif
if FireBullet = 1
delete sprite 9
BossBulletX(0) = BossX(0) + BossBulletOutOfGunX
BossBulletY(0) = BossY(0) + BossBulletOutOfGunY
FireBullet = 0
endif
`==============================================
`===========E_N_D__B_O_S_S__C_O_D_E============
`==============================================
endif
sync
loop
`======================================================
`==================F_U_N_C_T_I_O_N_S===================
`======================================================
#include "Functions.dba"
This is all of the function code. You need to place this in the same folder as the main game code. Name this file "Functions"
function PlayerBulletHitShield(Player,Shield)
if sprite hit(Player,Shield) = 1
BulletX(0) = PlayerX(0) + BulletOutOfGunX
BulletY(0) = BulletOutOfGunY
firing(0) = 0
endif
endfunction
function EnemyBulletHitShield(EnemyBullet)
if sprite hit(EnemyBullet,4) = 1
play sound 5
delete sprite (EnemyBullet)
d = EnemyBullet - 600
EnemyBulletX(d) = EnemyX(d) + EnemyBulletOutOfGunX
EnemyBulletY(d) = EnemyY(d) + EnemyBulletOutOfGunY
endif
endfunction
function EnemyBulletHitPlayer(EnemyBullet)
if sprite hit(1,EnemyBullet) = 1
delete sprite 1
play sound 3
PlayerX(0) = 300
PlayerY(0) = 400
Lifes(0) = Lifes(0) - 1 * 1
D3 = EnemyBullet - 600
EnemyBulletX(d3) = EnemyX(d3) + EnemyBulletOutOfGunX
EnemyBulletY(d3) = EnemyY(d3) + EnemyBulletOutOfGunY
sleep 1000
endif
endfunction
function PlayerBulletHitEnemy(Enemy,WaveN)
if sprite hit(3,Enemy) = 1
Wave(WaveN) = Wave(WaveN) + 1
delete sprite Enemy
delete sprite Enemy + 500
play sound 4
firing(0) = 0
BulletX(0) = PlayerX(0) + BulletOutOfGunX
BulletY(0) = PlayerY(0)
KillEnemy = Enemy - 100
EnemyBulletX(KillEnemy) = 2000
EnemyBulletY(KillEnemy) = 2000
EnemyX(KillEnemy) = 2000
EnemyY(KillEnemy) = 2000
endif
endfunction
function PlayerBulletHitBoss(Boss,PlayerBullet)
if sprite hit(Boss,PlayerBullet) = 1
play sound 4
firing(0) = 0
BulletX(0) = PlayerX(0) + BulletOutOfGunX
BulletY(0) = PlayerY(0) + BulletOutOfGunY
BossLife(0) = BossLife(0) - 1 * 1
MoveBoss(0) = rnd(1)
endif
endfunction
function BossBulletHitPlayer(BossBullet,Player)
if sprite hit(BossBullet,Player) = 1
delete sprite Player
play sound 3
PlayerX(0) = 300
PlayerY(0) = 400
lifes(0) = lifes(0) - 1 * 1
sleep 1000
endif
endfunction
This is the code that you need to change. What you do is load your images in in the correct order. You need to place this in the same folder as the above code. You also need to store your media in a folder named Media within your game folder.
Name this File "LoadMedia"
function LoadMedia()
set Dir "Media"
`Load your Images in the order below!!!!
`--------------------------------------------------
`--------------------------------------------------
`NOTE: IF YOU DO NOT LOAD IMAGES AS SAID BELOW
`YOUR GAME WILL NOT WORK!!!!!!!
`--------------------------------------------------
`--------------------------------------------------
`Load Player Image as Image #1
load image "Player.bmp",1
`Load Player Life Image as Image #2
load image "Player Life.bmp",2
`Load Player Bullet as Image #3
load image "Player Bullet.bmp",3
`Load Background Image as Image #4
load image "Background.bmp",4
`--------------------------
`NOTE THERE IS NOT IMAGE 5
`SKIP TO IMAGE #6
`--------------------------
`Load Your Shield as Image #6
`"Shield" is what is used to protect the Player Character
`Example is say a SandBag
load image "Shield.bmp",6
`Load Ammo Image as Image #7
load image "Ammo.bmp",7
`Load Boss Enemy as Image #8
load image "Boss.bmp",8
`Load Boss Bullet as Image #9
load image "BossBullet.bmp",9
`Load Enemies as Image #10
load image "Enemy.bmp",10
`Load Enemy Bullets as Image #11
load image "EnemyBullet.bmp",11
`-------------------------------------------------------------------
`Do not change the numbers just put your own sounds in that resemble
`The type of sound that is needed
`-------------------------------------------------------------------
`Load a Sound for the Players Guns
load sound "shoot.wav",1
`Load a Sound to Reload Players Guns
load sound "reload.wav",2
`Load a Sound to make a squish or injure noise for enemies
load sound "squish.wav",3
`Load a Sound to make a injured noise for Enemies
load sound "moan.wav",4
`Load a Sound that Resembles impact or a Hit
load sound "hit.wav",5
`Load your music
load music "mind trick.mid",1
load music "opponent.mid",2
play music 1
`This Will Paste your Background image to the screen
`Make your Background image 640, 480
paste image 4, 20,40
endfunction
http://www.angelfire.com/games5/db_games/