' 1945qb translated by Johnno from Naalaa
'2021-12-06 bplus mod splash screen / menu
'2021-12-07 bplus give the players plane more than 1 bullet!
xmax = 640
ymax = 480
' ARRAYS
width0 = 65
height0 = 65
width3 = 9
height3 = 19
width5 = 32
height5 = 32
width27 = 5
height27 = 5
width28 = 94
height28 = 31
width29 = 6
height29 = 11
width30 = 278
height30 = 141
width32 = 115
height32 = 58
width35 = 32
height35 = 32
width36 = 32
height36 = 32
quit = 0
dead = false
hit = 0
ammo = 300
repairActive = 0
ammoActive = 0
' LOAD ASSETS
' ===========
' Images
'
' Power ups
img
(36) = _LoadImage("data/ammo.png") ' ammunition
' Sounds
'
explosion
= _SndOpen("data/explosion.wav")plane_shot
= _SndOpen("data/plane_shot.wav")
' Fonts
'
' TILING THE BACKGROUND
' =====================
'backgroundX((640 / 32) + 1)
'backgroundY((480 / 32) + 1)
'transitionX((640 / 32) + 1)
'transitionY((480 / 32) + 1)
backgroundX(i) = i * 32
transitionX(i) = i * 32
backgroundY(a) = a * 32
transitionY(a) = a * 32
' A GAME MENU TO START WITH
' =========================
menu = 0
'_PutImage ((640 - width30) / 2, 5), img(30)
centerText
0, _Width, ymax
* .6, "Play Game" centerText
0, _Width, ymax
* .6 + 70, "Quit" centerText
0, _Width, ymax
* .6, "Play Game" centerText
0, _Width, ymax
* .6 + 70, "Quit"
'_PutImage ((640 - width28) / 2, height30 + 30), img(28)
'_PutImage (((640 - width28) / 2) - width29, height30 + (30 + menu * 19)), img(29)
menu = menu - 1
menu = menu + 1
menu = 0
menu = 1
_PutImage (transitionX
(i
), transitionY
(z
)), img
(4)
_PutImage (transitionX
(i
), transitionY
(z
)), img
(4)
restart:
' INITIALIZING VARIABLES
' =================================
nBullets = 100
frame = 0
explo_frame = 0
bigexplo_frame = 0
bigexplox = -70
bigexploy = -70
explo2_frame = 0
speed = 6
scrollspeed = 1
planex = 320
planey = 480 - 128
enemyshot(0) = 0
enemyshot(1) = 0
shot = 0
explox = -30
exploy = -30
explo2x = -30
explo2y = -30
score = 0
lives = 3
health = 100
bullseye = 1
shots_fired = 1
bigexploactive = 0
' SETTING THE POSITIONS OF THE ENEMY PLANES
' =========================================
enemyY
(i
) = 0 - Int(Rnd * 480) - 32 superenemyX
(i
) = Int(Rnd * 608) superenemyY
(i
) = 0 - Int(Rnd * 480) - 32 enemybulletX(i) = superenemyX(i) + 13
enemybulletY(i) = superenemyY(i) + 17
' SETTING THE POSITIONS AND STARTING IMAGES OF THE ISLANDS
' ========================================================
islandY
(i
) = 0 - Int(Rnd * 480) islandImage(i) = img(i + 21)
' SETUP POWER UPS
' ===============
repairSpeed = 2
ammoSpeed = 2
' THE 'ACTUAL' GAME LOOP
' ======================
_PutImage (transitionX
(i
), transitionY
(z
)), img
(4)
' CLEARING THE SCREEN
' ===================
' MOVING THE PLAYER WITH THE ARROW KEYS
' =====================================
' OH, AND SHOOTING WITH THE SPACEBAR
' ==================================
planey = planey - speed
planey = planey + 4
planex = planex - speed
planex = planex + speed
' find inactive bullet
bullets(i).x = planex + 27 ' 17
bullets(i).y = planey + 5
bullets(i).active = -1
shots_fired = shots_fired + 1
ammo = ammo - 1
' MOVING THE ENEMY PLANES
' =======================
enemyY
(z
) = 0 - Int(Rnd * 480) enemyY(z) = enemyY(z) + speed
superenemyX
(z
) = Int(Rnd * 608) superenemyY
(z
) = 0 - Int(Rnd * 480) superenemyY(z) = superenemyY(z) + speed
' MOVING THE ISLANDS
' ==================
islandY
(z
) = 0 - Int(Rnd * 480) islandImage
(z
) = img
(Int(Rnd * 3) + 21) islandY(z) = islandY(z) + 3
' CHECKING WHEN WE BEAT OR BEING BEATEN
' =====================================
' Collision with enemy?
collision planex, planey, width0, height0, enemyX(t), enemyY(t), width5, height5
'collision(r1x, r1y, r1w, r1h, r2x, r2y, r2w, r2h)
explo2x = enemyX(t)
explo2y = enemyY(t)
explox = enemyX(t)
exploy = enemyY(t)
enemyY
(t
) = 0 - Int(Rnd * 480) health = health - 25
bigexploactive = 1
bigexplox = planex
bigexploy = planey
planex = -70
planey = -70
enemyY
(t
) = 0 - Int(Rnd * 480)
'If shot = 1 Then
' Collision with player bullet and enemy
collision bullets(i).x, bullets(i).y, width3, height3, enemyX(t), enemyY(t), width5, height5
explo2x = enemyX(t)
explo2y = enemyY(t)
explox = enemyX(t)
exploy = enemyY(t)
enemyY
(t
) = 0 - Int(Rnd * 480) bullets(i).x = -30
bullets(i).y = -30
bullets(i).active = 0
score = score + 50
bullseye = bullseye + 1
'End If
' Collision with player and superenemy
collision planex, planey, width0, height0, superenemyX(t), superenemyY(t), width5, height5
explo2x = superenemyX(t)
explo2y = superenemyY(t)
explox = superenemyX(t)
exploy = superenemyY(t)
superenemyX
(t
) = Int(Rnd * 608) superenemyY
(t
) = 0 - Int(Rnd * 480) health = health - 25
bigexploactive = 1
bigexplox = planex
bigexploy = planey
planex = -70
planey = -70
superenemyX
(t
) = Int(Rnd * 608) superenemyY
(t
) = 0 - Int(Rnd * 480)
' Collision with player bullet and superenemy
collision bullets(i).x, bullets(i).y, width3, height3, superenemyX(t), superenemyY(t), width5, height5
explo2x = superenemyX(t)
explo2y = superenemyY(t)
explox = superenemyX(t)
exploy = superenemyY(t)
superenemyX
(t
) = Int(Rnd * 608) superenemyY
(t
) = 0 - Int(Rnd * 480) bullets(i).x = -30
bullets(i).y = -30
bullets(i).active = 0
score = score + 100
bullseye = bullseye + 1
' Collision with player and enemy bullet
collision planex, planey, width0, height0, enemybulletX(t), enemybulletY(t), width27, height27
health = health - 10
bigexploactive = 1
bigexplox = planex
bigexploy = planey
enemybulletX(t) = -30 'had players bullets here!!!
enemybulletY(t) = -30
explox2 = enemybulletX(t)
exploy2 = enemybulletY(t)
explox = enemybulletX(t)
exploy = enemybulletY(t)
enemybulletX(t) = superenemyX(t) + 14 '1
enemybulletY(t) = superenemyY(t) + 17 '7
enemyshot(t) = 0
' FLYING OVER THE ENDLESSLY SCROLLING SEA
' =======================================
backgroundY(w) = backgroundY(w) + 3
backgroundY(w) = backgroundY(w) - 512
_PutImage (backgroundX
(q
), backgroundY
(w
)), img
(4)
' WHICH LOOKS DULL WITHOUT ISLANDS
' ================================
_PutImage (islandX
(o
), islandY
(o
)), islandImage
(o
)
' KEEPING OUR PLANE IN THE SCREEN AND DISPLAY IT
' ==============================================
frame = frame + 1
frame = 0
planex = 0
planey = 0
planex = 640 - width0
If planey
+ height0
> 480 - 64 Then planey = 480 - height0 - 64
' WE HAVE TO SEE WHAT WE ARE FIGHTING
' ===================================
_PutImage (enemyX
(x
), enemyY
(x
)), img
(frame
+ 5) enemybulletY(i) = enemybulletY(i) + 10
enemyshot(i) = 1
enemybulletX(i) = superenemyX(i) + 14 '1
enemybulletY(i) = superenemyY(i) + 17 '7
enemyshot(i) = 0
enemybulletX(i) = superenemyX(i) + 14 '1
enemybulletY(i) = superenemyY(i) + 17 '7
enemyshot(i) = 0
_PutImage (enemybulletX
(i
), enemybulletY
(i
)), img
(27) _PutImage (superenemyX
(x
), superenemyY
(x
)), img
(frame
+ 24)
' AND WITH WHAT
' =============
If bullets
(j
).y
> 0 And bullets
(j
).active
Then bullets(j).y = bullets(j).y - speed * 2
_PutImage (bullets
(j
).x
, bullets
(j
).y
), img
(3) bullets(j).x = -30
bullets(j).y = -30
bullets(j).active = 0
' A NICE EXPLOSION
' ================
explo_frame = explo_frame + 1
_PutImage (explox
, exploy
), img
(explo_frame
+ 8) explo_frame = 0
explox = -30
exploy = -30
' A SECOND NICE EXPLOSION
' =======================
explo2_frame = explo2_frame + 1
_PutImage (explo2x
, explo2y
), img
(explo2_frame
+ 8) explo2_frame = 0
explo2x = -30
explo2y = -30
' A BIGGER EXPLOSION
' ==================
enemyY
(s
) = 0 - Int(Rnd * 480) superenemyX
(s
) = Int(Rnd * 608) superenemyY
(s
) = 0 - Int(Rnd * 480) bigexplo_frame = bigexplo_frame + 1
bigexploactive = 0
bigexplo_frame = 0
bigexplox = -70
bigexploy = -70
lives = lives - 1
planex = 320
planey = 480 - 128
health = 100
_PutImage (bigexplox
, bigexploy
), img
(bigexplo_frame
+ 14)
' Power Ups
' HEALTH
'
repairActive = 1
repairY = repairY + repairSpeed
repairActive = 0
collision planex, planey, width0, height0, repairX, repairY, width35, height35
health = health + 20
repairActive = 0
' AMMUNITION
'
ammoActive = 1
ammoY = ammoY + ammoSpeed
ammoActive = 0
collision planex, planey, width0, height0, ammoX, ammoY, width36, height36
ammo = ammo + 10
ammoActive = 0
' INFORMATION PANEL
' =================
c = 143
Line (7, 480 - 22 + z
)-(7 + health
, 480 - 22 + z
), _RGB32(255, c
, 0) c = c - 44
c = c + 44
_PrintString (5, 480 - 48), "Accuracy: " + Str$((bullseye
/ shots_fired
) * 100) + "%"
' IF ALL LIVES ARE GONE, THEN IT`S GAME OVER
' =========================================
' DRAWING EVERYTHNG AND WAITING
' =============================
' AND PAUSING THE GAME IF HIS MAJESTY WANTS SO
' ============================================
goAgain$ = topTenGoAgain$(score)
'=======================================================
Sub collision
(r1x
, r1y
, r1w
, r1h
, r2x
, r2y
, r2w
, r2h
) If (r1x
+ r1w
>= r2x
And r1x
<= r2x
+ r2w
And r1y
+ r1h
>= r2y
And r1y
<= r2y
+ r2h
) Then hit = 1
hit = 0
Sub centerText
(x1
, x2
, midy
, s$
) ' ' if you want to center fit a string between two goal posts x1, and x2
' This FUNCTION creates a file in the same folder as your .bas source or .exe
'EDIT: 2019-07-29 change to FUNCTION to combine Top Ten update functions with Go Again reply.
Color &HFFFFFFFF, &HFF000000
fName$ = "Top 10 Scores for 1945.txt" '<<< since this is toolbox code change this as needed for app
n = n + 1
If compareScore
>= score
And settleScore
= 0 Then Print "You have made the Top Ten!" Input "Type your name here: ", names$
(n
) scores(n) = compareScore
settleScore = -1
n = n + 1
If n
<= 10 Then names$
(n
) = name$: scores
(n
) = score
scores
(n
) = score: names$
(n
) = name$
Print "There is a slot open for your name and score." Input "Enter your name here (nothing quits): ", name$
n
= n
+ 1: names$
(n
) = name$: scores
(n
) = compareScore
Print i
, names$
(i
), scores
(i
) Print "You are first into file!" Input "Enter your name here (nothing quits):";
name$
Print:
Input "Press Enter to play again, any + Enter to quit... "; dummy$
topTenGoAgain$ = dummy$