#################################
# BASIC Tenliners Contest 2020  #
#                               #
# Air Combat Simulator        #
# (c) 2020 Roman Werner @romwer #
# email: roman.werner@gmail.com #
#################################

"Your country is under attack! This is not a drill! All drone pilots to the base!". This IS the moment you have been trained for. In a few minutes you will take control over a high-end drone fighter equiped with a SASER canon (SASER = sound amplification by stimulatied emission of radiation). The objective is to stop any enemy targets in sight. A special helmet blanks out any real world objects so that you can clearly focus on your targets. Despite the tech, keep your altitude not only above ground but also below 24576 feet otherwise the multi-million dollar drone will crash or be torned apart.

Tip: To find your first enemy make a roll to the right and then follow the sun.


Features
========
- 2 different types of enemies: Military Tanks and Fighter Jets
- Simulating 3D air combat
- Open World, fly in any directions and as far as you like
- Navigate on realistic instruments: Altitude and Compass
- Status counter to check how many enemies you have eliminated.


Task and Goal
=============
- Take out as many enemy intruders as you can.


Control:
========
Keyboard WASD (W = Dive / A = Roll to the left / S = Climb / D - Roll to the right)
Align the crosshair of your fighter exactly with the enemy on screen (tank or plane) to automatically SASER strike your target.

After a crash use <Space> to restart.


Game Requirements:
==================
- C64/C128* with BASIC 2.0 runtime environment (or compatible)
- 1 Player

*Also playable on Windows/MacOS/iOS/Android (C64 Emulator required)


Starting in VICE: C64 emulator (http://vice-emu.sourceforge.net/):
==================================================================
Start the emulator and then drag and drop the "aircombatsimulator.prg" into the VICE window.
-or-
Load the program with the command: load "aircombatsimulator.prg",8
Then start the program with:       run


Air Combat Simulator BASIC program code:
========================================
0poke53280,0:poke53281,0:poke650,128:print"{clear}":v=8:r=3:t=32:l=40:c$="{cm p}RFCDE{cm y}RFFCDDEFFCCCDD"
1x=1364:forj=1tol:b$=b$+" ":v$=v$+"{down}":b$(3)=b$(3)+"C":next:forj=0to2:b=6-j:fori=7to46
2q$=mid$(c$,k+i/6,1):b$(j)=b$(j)+q$:b$(b)=q$+b$(b):next:k=k+7:next:o=1024:q=o:w=24:e=l
3printleft$(v$,v)b$b$(r)b$;:geta$:r=r+(a$="d")*-(r>.)+(a$="a")*(r<6):pokex,91:poked+a,t
4v=v+(a$="w")*-(v>.)+(a$="s")*(v<20):a=a-.5+r/6+39*(a>39)-39*(a<.):pokeu,t:c=z/10
5u=(1144+(v-5)*l-c)*abs(v>3andc>.andc<l):pokeu,81:iff=xthene=int(rnd(1)*(o-l)):g=g+1
6pokef,t:f=(1343+(v-m)*l-(z-e))*abs(z>=eandz<e+landv-m<19):iff=xthenm=int(rnd(1)*15)and11
7q=q+(v-9)*abs(v-9):d=o+(int(h+v)*l)+int((w-int(h+v))/3)*l:poked+a,45:z=3-r+zando-1
8print"{home}{cm e}"g,"alt"q"{left} "tab(35)mid$("n-e-s-w-n-",z/128+1,3):ifh+v>wthenh=0:poked+a,t:a=rnd(1)*l
9pokef,113:h=h+(20-v)/15:on-(q>.andq<w*o)goto3:pokeo+rnd(1)*o,102:on-(peek(197)<>60)goto9:run


Air Combat Simulator BASIC program code (PUR-80 version using command abbreviations):
=====================================================================================
0pO53280,0:pO53281,0:pO650,128:?"{clear}":v=8:r=3:t=32:l=40:c$="{cm p}RFCDE{cm y}RFFCDDEFFCCCDD"
1x=1364:fOj=1tol:b$=b$+" ":v$=v$+"{down}":b$(3)=b$(3)+"C":nE:fOj=0to2:b=6-j:fOi=7to46
2q$=mI(c$,k+i/6,1):b$(j)=b$(j)+q$:b$(b)=q$+b$(b):nE:k=k+7:nE:o=1024:q=o:w=24:e=l
3?leF(v$,v)b$b$(r)b$;:gEa$:r=r+(a$="d")*-(r>.)+(a$="a")*(r<6):pOx,91:pOd+a,t
4v=v+(a$="w")*-(v>.)+(a$="s")*(v<20):a=a-.5+r/6+39*(a>39)-39*(a<.):pOu,t:c=z/10
5u=(1144+(v-5)*l-c)*aB(v>3aNc>.aNc<l):pOu,81:iff=xtHe=int(rN(1)*(o-l)):g=g+1
6pOf,t:f=(1343+(v-m)*l-(z-e))*aB(z>=eaNz<e+laNv-m<19):iff=xtHm=int(rN(1)*15)aN11
7q=q+(v-9)*aB(v-9):d=o+(int(h+v)*l)+int((w-int(h+v))/3)*l:pOd+a,45:z=3-r+zaNo-1
8?"{home}{cm e}"g,"alt"q"{left} "tA35)mI("n-e-s-w-n-",z/128+1,3):ifh+v>wtHh=0:pOd+a,t:a=rN(1)*l
9pOf,113:h=h+(20-v)/15:on-(q>.aNq<w*o)gO3:pOo+rN(1)*o,102:on-(pE(197)<>60)gO9:rU

Tip: Copy/paste the program-Code into CBM prg Studio (http://www.ajordison.co.uk/).
There you can see the commands in nice color highlighting and you can directly execute the game in an emulator of your choice.


Air Combat Simulator Tenliner explained (000=row 0/100=row 1/...):
==================================================================
000 poke53280,0: rem set background color to black
001 poke53281,0: rem set border color to black
002 poke650,128: rem enable automatic key press repeat
003 print"{clear}": rem clear screen
004 v=8: rem initial up/down angle 0=max.decline / 9=straight / 20=max.climb
005 r=3: rem inital left/right angle 0=max.left 3=straight 6=max.right
006 t=32: rem contacts value for space character
007 l=40: rem number of chars per line
008 c$="{cm p}RFCDE{cm y}RFFCDDEFFCCCDD": rem compressed elements of horizon

100 x=1364: rem constant screen position/address to place crosshair
101 forj=1tol: rem for 40 times/characters...
102 b$=b$+" ": rem build string with blanks to erase last horizon position
103 v$=v$+"{down}": rem build string to use for cursor positioning
104 b$(3)=b$(3)+"C": rem build string with straight horizon (3=middle position)
105 next
106 forj=0to2: rem for horizon elements 0,1,2...
107 b=6-j: rem ... and horizon elements 6,5,4...
108 fori=7to46: rem build the horizon strings based on the horizon elements

200 q$=mid$(c$,k+i/6,1): rem get element but change only every sixth character
201 b$(j)=b$(j)+q$: rem add element to line of horizon 0,1,2
202 b$(b)=q$+b$(b): rem add element to line of horizon 6,5,4
203 next
204 k=k+7: rem change offset for the next seven elements in c$
205 next
206 o=1024: rem base screen position/address in top left corner
207 q=o: rem q=altitude - use screen position as initial altitude ;)
208 w=24: rem constant value for last row
209 e=l: rem set first enemy position to 40

300 printleft$(v$,v)b$b$(r)b$;: rem print horizon at current angle (v)
301 geta$: rem read keyboard input
302 r=r+(a$="d")*-(r>.)+(a$="a")*(r<6): rem change angle depending on key pressed
303 pokex,91: rem poke crosshair symbol to screen position
304 poked+a,t: rem clear last position of ground '-' symbol

400 v=v+(a$="w")*-(v>.)+(a$="s")*(v<20): rem change angle depending on key pressed
401 a=a-.5+r/6+39*(a>39)-39*(a<.): rem calulate next offset (0-39) for '-'
402 pokeu,t: rem clear last position of sun
403 c=z/10: rem z=world dimension (0-1023)/c=viewpoint (0-400) when sun is visible

500 u=(1144+(v-5)*l-c)*abs(v>3andc>.andc<l): rem calculate sun position
501 pokeu,81: rem sun=81 - when not in range it pokes to address 0!!! :o)
502 iff=xthene=int(rnd(1)*(o-l)):g=g+1: rem when crosshair meets enemy then calculate new enemy horizontal position/increase score

600 pokef,t: rem clear last position of enemy
601 f=(1343+(v-m)*l-(z-e))*abs(z>=eandz<e+landv-m<19): rem calculate new viewpoint when showing enemy
602 iff=xthenm=int(rnd(1)*15)and11: rem when crosshair meets enemy then calculate new enemy vertical position (tank or plane)

700 q=q+(v-9)*abs(v-9): rem calculate change in altitude depending on angle
701 d=o+(int(h+v)*l)+int((w-int(h+v))/3)*l: rem calculate next screen position for ground symbol
702 poked+a,45: rem poke ground symbol '-' to screen position + horizontal offset (0-39)
703 z=3-r+zando-1: rem change current world position (0-1023) depending on left/right angle

800 print"{home}{cm e}"g,"alt"q"{left} "tab(35)mid$("n-e-s-w-n-",z/128+1,3): rem print score, altitude and compass to screen (top row)
801 ifh+v>wthenh=0:poked+a,t:a=rnd(1)*l: rem when ground symbol reaches bottom row then calculate new horizontal position (0-39)

900 pokef,113: rem poke enemy tank/plane=113 to screen position
901 h=h+(20-v)/15: rem calculate next vertical position for ground symbol '-'
902 on-(q>.andq<w*o)goto300: rem continue while altitude is >0 and <24576
903 pokeo+rnd(1)*o,102: rem game over - fill screen with debris elements
904 on-(peek(197)<>60)goto900: rem wait for space key
905 run: rem restart game

2020 rem basic tenliners contest / (c) roman werner @romwer roman.werner@gmail.com
