' 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!
'2021-12-11 bplus added Top Ten Score tracker combined with Go again function v4
' from v5 johnno's fixed collision rectangles
'2021-12-12 bplus allows bullet if 10 frames have passed since last, fired, variable
'2021-12-12 bplus review all variables under Option _Explicit and search
' removed quit, dead variables found typo explox2 supposed to be explo2x
' decreased ammo to 100 same as max active bullets
' increased health +50 because loose health getting to health st it's no help!!!
' made bullet hitting plane same as crashes -25, so you hear 4 hits on plane you know goodbye plane
Const xmax
= 640, ymax
= 480
' ARRAYS
Dim width0
, height0
, width3
, height3
, width5
, height5
, width27
, height27
, width28
, height28
, width29
, height29
Dim width30
, height30
, width32
, height32
, width35
, height35
, width36
, height36
, ammo
, repairActive
, ammoActive
width0 = 57
height0 = 42
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 = 18
height35 = 28
width36 = 18
height36 = 28
hit = 0
ammo = 100
repairActive = 0
ammoActive = 0
' LOAD ASSETS
' ===========
' Images
'
' Power ups
img
(36) = _LoadImage("data/ammo.png") ' ammunition
' Sounds
'
Dim As Long shoot
, explosion
, collide
, plane_shot
, pu_health
, pu_ammo
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)
Dim nBullets
, frame
, explo_frame
, bigexplo_frame
, bigexploX
, bigexploY
, explo2_frame
, speed
, planeX
, planeY
, shot
, exploX
, exploY
Dim explo2X
, explo2Y
, score
, lives
, health
, bullseye
, shots_fired
, bigexploactive
, repairX
, repairY
, repairSpeed
, ammoX
, ammoY
, ammoSpeed
Dim fired
, t
, w
, q
, o
, x
, j
, s
, c
, goAgain$
nBullets = 100
restart:
' INITIALIZING VARIABLES
' =================================
ammo = 100 ' EDIT renew ammo
frame = 0
explo_frame = 0
bigexplo_frame = 0
bigexploX = -70
bigexploY = -70
explo2_frame = 0
speed = 6
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
' ======================
fired = fired - 1 ' >>>> use frame count instead of timer to allow shooting a bullet
' 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
fired = 10
' 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 - 25
bigexploactive = 1
bigexploX = planeX
bigexploY = planeY
enemybulletX(t) = -30 'had players bullets here!!!
enemybulletY(t) = -30
explo2X = enemybulletX(t)
explo2Y = 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 + 50
If health
> 100 Then health
= 100 repairActive = 0
' AMMUNITION
'
ammoActive = 1
ammoY = ammoY + ammoSpeed
collision planeX, planeY, width0, height0, ammoX, ammoY, width36, height36
ammo = ammo + 10
ammoActive = 0
' INFORMATION PANEL
' =================
c = 50
Line (7, 480 - 22 + z
)-(7 + health
, 480 - 22 + z
), _RGB32(0, c
, 0) c = c - 50
c = c + 50
' 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$