'Archery 1985 by Brain Blankenship
'2019 Archery By Cobalt
'8/13/2019|
'V0.4
'-Sprites\Title\Options screens done
'V0.6
'-Scoreboard done
'-target movement done
'-arrow movement done
'V0.7
'-collision detection
'8/14/2019
'V0.8
'player 2 frames
'Random site creation
'8/15/2019
'v0.9
'Computer AI for player 2
'Computer vs computer possible
'8/16/2019
'V1.0b
'Highscore file\list added
'Bug-Computer goes first in 1 player game fixed(Thanks Bplus!)
'Computer only play option added
'V1.0c
'Bug-Player 2 goes first in 2 player game fixed(Thanks TempodiBasic)
'Error- corrected ORIGNALLY to ORIGINALLY in title screen(Thanks TempodiBasic)
'-------------CONSTANTS----------------
CONST Black
= &HFF000101~&
, Cyan
= &HFF01A0A0~&
, Magenta
= &HFF941090~&
, OffWhite
= &HFFC7C0C0~&
, Green
= &HFF1B9010~&
, CtrWhite
= &HFFCAC0C0~&
'--------------------------------------
'-------ARRAYS & SHARED VARIABLES------
'--------------------------------------
'---------------LAYERS-----------------
Layer
(1) = _NEWIMAGE(640, 400, 32) 'mix layerLayer
(2) = _NEWIMAGE(320, 200, 32) 'Title Screen LayerLayer
(3) = _NEWIMAGE(320, 200, 32) 'Sprite sheet layerLayer
(4) = _NEWIMAGE(320, 200, 32) 'Collision layerLayer
(5) = _NEWIMAGE(320, 200, 32) 'Extra/Scoreboard layerLayer
(6) = _NEWIMAGE(320, 200, 32) 'Input layer/Prebuild layerLayer
(7) = _NEWIMAGE(320, 200, 32) 'high score layer'--------------------------------------
'-----------ARROW HIT SOUND------------
PLAY "t230l64" 'setup sound play rate HitSound$ = "o1bagfedc"
'--------------------------------------
Draw_Sprites
Draw_Title_Screen
Title_Animation
'-------Inital Values------------------
Target.Speed = 1
Target.Y = 0: Target.OrigY = 0
Target.X = 309: Target.OrigX = 309
Arrow.Speed = 0
Arrow.OrigY = 135: Arrow.Y = Arrow.OrigY
Arrow.OrigX = 69: Arrow.X = Arrow.OrigX
ExitFlag%% = FALSE
Turn%% = TRUE
Computer.Class = 3 'skill level of computer(experimental)
Noise%% = Computer_AI 'adds little randomness to computer shots
'-------------MAIN LOOP----------------
ClearLayer Layer(5)
Game_Option_Screen
Scoreboard_Setup
MainGame
IF Calc_Score
(0) >= Calc_Score
(1) THEN Winner%%
= 0 ELSE Winner%%
= 1 HighScore_Screen
IF QuitGame%%
THEN ExitFlag%%
= TRUE
PRINT "Thank you for playing Archery 2019!" PRINT "leave any comments, suggestions, or bugs at:" PRINT "www.QB64.org/Forum/index.php?topic=1627.0" '--------------------------------------
Result~%% = 0
Result~%% = Result~%% + Shots(Who%%, F%%, S%%)
Calc_Score = Result~%%
Result~%% = 0
Test~&
= POINT(25 + X%
+ I%%
, Y%
+ 3) IF R~%%
> 0 THEN Result~%%
= R~%%: I%%
= 5 Collision_Check = Result~%%
Result%% = 0
CASE 5 'Robin Hood unbeatable 150! Computer_AI%% = Result%%
LOCATE 4 + Shot%%
+ (P%%
* 4), 12 + Flight%%
* 4 PRINT Shots
(P%%
, Flight%%
, Shot%%
)
ClearLayer Layer(3)
'Original target draw /w color fix
DRAW "bm318,140c" + STR$(Cyan
) + "d30l1u30l1d30u6l1c" + STR$(Magenta
) + "u18l1d18l1u18d6l1c" + STR$(OffWhite
) + "d6l1u6" 'original arrow draw /w color fix
DRAW "bm10,155c" + STR$(Cyan
) + "r20l20c" + STR$(Magenta
) + "h3f3g3e3c" + STR$(OffWhite
) + "bm+2,+0h3f3g3e3c" + STR$(Magenta
) + "bm+2,+0h3f3g3e3bm+15,-2c" + STR$(OffWhite
) + "d4u1r1u2d1r1" _PUTIMAGE (0, 0), Layer
(1), Layer
(3), (310, 140)-STEP(8, 30) 'move target to sprite sheet _PUTIMAGE (0, 32), Layer
(1), Layer
(3), (7, 152)-STEP(24, 6) 'move arrow to sprite sheet ClearLayer Layer(1)
DRAW "bm41,70e30r10d30l8u12l8g12l11bm+34,-24d6l7e7bm+11,-5d30r8u15m+15,+15r10h18u12l14bm+4,+5d5r4u5l4" DRAW "BM+20,-5r30d12l8u4l17f15r3u5r7d12l15h20u10r4bm+37,-0r8d10r8u10r8d30l8u10l8d10l8u30bm+30,-0r20d6l15d8r8d5l8d6r15d5l20u30" DRAW "bm+26,-0d30r8u15m+15,+15r10h18u12l14bm+4,+5d5r4u5l4bm+17,-5d10f16d4r8u30l8d17h7u10l8" DATA 46,90,129,150,180,206,243 PAINT (t%
, 68), Magenta
, OffWhite
_PUTIMAGE (1, 0), Layer
(1), Layer
(2), (1, 0)-(319, 199) _PUTIMAGE (310, 140), Layer
(3), Layer
(2), (0, 0)-STEP(7, 30) 'target ClearLayer Layer(1)
PRINT " Score as many points as possible by" PRINT " hitting the target close to the" PRINT " center. Press the space bar to shoot." PRINT " You get three trys from each of five" PRINT " sites, highest score wins. 3 to watch" PRINT " the computer battle it out." PushScreen 5
PRINT "Number of Players(1/2[3])?" PushScreen 5
Flag
= Flag
+ 2 ^ (VAL(kbd$
) - 1) 'set bit 0 if 1 player, bit 1 for 2 player Turn%% = TRUE
PushScreen 5
Player$(0) = Get_Player_Name(0)
PushScreen 5
Player$(1) = Get_Player_Name(1)
PushScreen 5
IF kbd$
= "y" THEN Flag
= 4: Player$
(1) = "Computer" Player$(0) = "Computr1"
Player$(1) = "Computr2"
ComputerOnly%% = TRUE: Turn%% = FALSE 'watch the computer play itself!
Flag = 4 'set player 2 to computer(needed for computer only play)
ClearLayer Layer(1)
PushScreen 5
Get_Player_Name = Result$
C(1) = Magenta: C(2) = Magenta: C(3) = Magenta: C(4) = OffWhite: C(5) = Cyan
CI%% = 1
'-----load previous scores(if any)------
INPUT #1, Count%%
'how many scores recored Count%% = 0
'-----------------------------------------
'-------tack new score on bottom-------
Count%% = Count%% + 1
Score.
Name(Count%%
) = Player$
(Winner%%
) Score.
Val(Count%%
) = Calc_Score
(Winner%%
) '--------------------------------------
'------------Ultra basic sort----------
'---------------------------------------
'--------------save scores--------------
IF Count%%
= 11 THEN Count%%
= 10 'drop lowest score '---------------------------------------
i%% = 0
IF KBD$
= CHR$(27) THEN ExitFlag%%
= TRUE: QuitGame%%
= TRUE
IF UCASE$(KBD$
) = "N" THEN ExitFlag%%
= TRUE: QuitGame%%
= TRUE
'erase highscore list
'---------box area----------
LINE (9 + i%%
, 9 + i%%
)-STEP(263 - i%%
* 2, 138 - i%%
* 2), C
(CI%%
), B
'---------------------------
i%% = i%% + 1
CI%% = CI%% + 1
Reset_Game
Target.Y = Target.Y + Target.Speed
_PUTIMAGE (Target.X
, Target.Y
), Layer
(3), Layer
(6), (0, 0)-STEP(8, 30) 'target 'collision layer
ClearLayer Layer(4)
_PUTIMAGE (Target.X
, Target.Y
), Layer
(3), Layer
(4), (0, 0)-STEP(8, 30) 'target _PUTIMAGE (318, 0)-STEP(1, 199), Layer
(5), Layer
(4), (319, 0)-(319, 199) 'target
Arrow.X = Arrow.X + Arrow.Speed
_PUTIMAGE (Arrow.X
, Arrow.Y
), Layer
(3), Layer
(6), (0, 32)-STEP(24, 6) 'arrow
Arrow.OrigX
= INT(RND * 240) + 10 Arrow.OrigY
= INT(RND * 50) + 120
Reset_Shot 99, 99, 0 'reset frame and flight
FOR x%%
= 0 TO 1 'reset score Shots(x%%, y%%, z%%) = 0
SUB Reset_Shot
(Shot%%
, Shoot%%
, Hit~%%
) STATIC Flight%%
, Frame%%
, Player%%
'-------assign score-------
Shots
(Player%%
, Frame%%
, Flight%%
) = Hit~%%
MOD 16 '--------------------------
'-----increment flight-----
Flight%% = Flight%% + 1
IF Flight%%
= 3 THEN '3 flights per frame Frame%% = Frame%% + 1: Flight%% = 0: New_Site
IF Flag
AND 2 OR Flag
AND 4 THEN 'is there a second player or computer? IF Player%%
THEN 'player 2 just loosed, next frame for player 1 Player%% = 0: Frame%% = Frame%% + 1: Flight%% = 0: New_Site
ELSE 'let player 2 loose his first frame Player%% = 1: Flight%% = 0
'--------------------------
Target.Y = Target.OrigY
Target.Speed = 1
Arrow.Y = Arrow.OrigY
Arrow.X = Arrow.OrigX
IF Shot%%
= 99 AND Shoot%%
= 99 THEN Flight%%
= 0: Frame%%
= 0 Shot%% = FALSE
Shoot%% = FALSE
IF Frame%%
= 5 THEN Hit~%%
= 99 ELSE Hit~%%
= 0 'end game trigger Noise%% = Computer_AI 'adds little randomness to computer shots
ClearLayer Layer(5)
LINE (319, 0)-(319, 199), Green
, BF
ClearLayer Layer(5)
_PUTIMAGE (7 + i%
, 152), Layer
(3), Layer
(5), (0, 32)-STEP(24, 6) 'arrow _PUTIMAGE (8 + i%
, 152), Layer
(3), Layer
(5), (0, 32)-STEP(24, 6) 'arrow ClearLayer Layer(5)
'-----controls-----
IF Fire%%
AND (NOT Shot%%
) THEN Shoot%%
= TRUE: Shot%%
= TRUE: Fire%%
= FALSE
': ExitFlag%% = TRUE '-----------------
'------Logic------
IF Shoot%%
THEN Hit~%%
= Collision_Check
(Arrow.X
, Arrow.Y
) IF Shoot%%
THEN Arrow.Speed
= 3 ELSE Arrow.Speed
= 0 IF Target.Y
= 201 THEN Target.Speed
= 0 IF Target.Y
= 201 AND (NOT Shot%%
) THEN Shot%%
= TRUE
'if player doesn't shoot then they forefit IF Target.Speed
= 0 AND Shot%%
AND (NOT Shoot%%
) THEN Reset_Shot Shot%%
, Shoot%%
, Hit~%%: Fire%%
= FALSE
Hit~%% = 0
Arrow.Y = Arrow.Y + 1
'-computer player-
Dist% = 309 - Arrow.OrigX '~how far to end of feild
Tim%% = Dist% \ 3 + Noise%% 'time from loose to hit+random factor
IF Target.Y
+ Tim%%
>= Arrow.OrigY
AND (NOT Shot%%
) THEN Fire%%
= TRUE
'-----------------
'-Display update--
ClearLayer Layer(6)
Display_Scoreboard
Move_Target
Move_Arrow
PushScreen 6
'-----------------
IF Hit~%%
= 99 THEN ExitFlag%%
= TRUE
'game over