'--------constants----------------------------------------------------------------------------------------------------------------------------------
CONST MENU_BUILDSTR
= "2.2.20.01.01" CONST RES_X
= 1280 'screen horizontal resolution, set to -1 to match the dsektop CONST RES_Y
= 720 'screen vertical resolution, set to -1 to match the dsektop CONST FPS
= 100 'set target frames per seconds to 100 for proper physicss speed CONST DEBUGMODE
= 0 'initial state of debug mode CONST FULLSCREENMODE
= 0 'set 1 for fullscreen on startup, other value to window mode CONST RES_X_TARG
= 1920 'world target horizontal resolution CONST RES_Y_TARG
= 1080 'world target vertical resolution CONST MAX_COL
= 247 'max. color number to use of 255 CONST PLAYER_COUNT_INI
= 3 'Initial players count CONST POCET_GUL_INI
= 20 'Initial non player balls count CONST PLAYER_COUNT_MAX
= 32 'Maximum players count CONST PLAYER_NET_MAX
= 8 'Max. number of network players CONST PLAYER_NET_MIN
= 2 'First network control enabled player CONST POCET_GUL_MAX
= 32 'Maximum balls count CONST STRAT_COUNT_MAX
= 20 'Maximum players strategies CONST PLAY_BALL_R
= 20 'Players ball size CONST V_MAX
= 300 / FPS
'Max player ball velocity CONST ACC_X
= 10 / FPS
'Balls acceleration X CONST ACC_Y
= 10 / FPS
'Balls accelereation Y CONST FRICTION
= 0.998 'Space fricition coeffifcient CONST ENERGY_ALL_MIN
= 500 'min.starting energy of all players together CONST ENERGY_PLAYER_MIN
= 50 'min. player's starting energy CONST ENERGY_PLAYER_MAX
= 150 'max. player's starting energy CONST ENERGY_DEC
= 5 / FPS
'ball energy decrement CONST REACTIME_AVG_NORMAL
= 0 * FPS
'Average AI reaction time in sec*FPS CONST CHYBASMERU_NORMAL
= 0.0 'Improper reaction rate CONST PRIESTOR_MIN
= PLAY_BALL_R
+ 100 CONST DELAY_ROUNDSTART
= 8 'delay in seconds after round end to accept resume CONST DELAY_MATCHEND
= 20 'delay in seconds after match end to accept resume CONST FREEZE_TIME
= 1.0 * FPS
'player freeze time after getting tag in seconds CONST SCORE_POS_X
= 50 'Score horizontal draw position CONST SCORE_DELTA_Y
= 13 'Score draw - vertictal offset from screen top CONST SCORE_DELTA_X
= 350 'Score draw - players score horizontal offset CONST SCORE_NAME_LEN
= 120 'Score draw - horizontal space for player name CONST BOOST_V_KOEF
= 3.0 'boost factor of extra maximum speed CONST BOOST_TRVANIE
= 1 * FPS
'boost duration CONST BOOST_TIME
= 1 * FPS
'min time between boosts in sec*fps CONST MENUCURSOR_COLOR
= 15 'Menu cursor color CONST MENUITEM_COLOR
= 7 'Menu cursor color CONST MENU_PLAYERS_COUNT
= 8 'Number of players in menu CONST FONT_W
= 8 'Font width in pixels CONST FONT_H
= 16 'Font height in pixels CONST GAMESTICK_DEADZONE
= 0.05 'gamepad stick axis maximum value considered as zero CONST CPU_CONTROLID
= PLAYER_NET_MAX
+ 1 'CPU controller id CONST HOSTIP_DEFAULT
= "" '"localhost" ' CONST HOSTPORT_DEFAULT
= 7432 CONST GETITEM_SYNC
= "SNC" 'network trasfer item code CONST GETITEM_STAV
= "SNS" 'network trasfer item code CONST GETITEM_BAL
= "SNB" 'network trasfer item code CONST GETITEM_PBAL
= "SNP" 'network trasfer item code CONST GETITEM_KLAV
= "SNK" 'network trasfer item code CONST GETITEM_HRAC
= "SNH" 'network trasfer item code CONST GETITEM_MESG
= "SNM" 'network trasfer item code CONST GETITEM_STAT
= "SNT" 'network trasfer item code CONST NET_TIMEOUT_LIMIT
= 10 'timeout to disconnect in seconds CONST NET_TIMEOUT_SYNC
= 0.01 'timeout to get synced in seconds CONST MSG_COUNT_MAX
= 20 'max. messages displayed CONST MSG_LEN_MAX
= 80 'max. length of message CONST MSG_DUR_STD
= 20 'message standard duration in seconds CONST MSG_COL
= 7 'message standard color CONST UPDATE_PER_BAL
= 0.1 'all balls network update period in seconds CONST UPDATE_PER_PLBAL
= 0.04 'player balls network update period in seconds CONST UPDATE_PER_HRAC
= 0.1 'players network update period in seconds CONST UPDATE_PER_STAV
= 0.04 'world state network update period in seconds CONST AUTOSTART_SEC_MAX
= 180 'max game autostart time
'--------type definitions----------------------------------------------------------------------------------------------------------------------------
TYPE vektor
'general 2D vector type
TYPE tstav
'game world state type (cca 100B) vmax
AS SINGLE 'maximum unboosted ball velocity pocetgulzvoleny
AS INTEGER 'number of balls desired pocetgulx
AS INTEGER 'number of balls in bottom row pocetguly
AS INTEGER 'number of balls in left column energy_allmin
AS SINGLE 'all players starting energy sum energy_playermin
AS SINGLE 'minimum starting energy of player energy_playermax
AS SINGLE 'maximum starting energy of player energy_player_start
AS SINGLE 'player's starting energy energydec
AS SINGLE 'energy decrease unit balbudeto
AS INTEGER 'successor tagged ball idx koniec_kola
AS _BYTE 'end of round flag (0=no end, 1=end of round, 2=end fo round and match) massallowed
AS _BYTE 'calculate balls with different masses pauza
AS _BYTE 'game pause flag (0 or 1) gameplay
AS _BYTE 'state of session: 0=menu, 1=gameplay zacinabal
AS INTEGER 'initially tagged ball idx boostallowed
AS _BYTE 'player boost mode allowed (0 or 1) syncstr
AS STRING * 3 'net synchronisation string code synctime
AS DOUBLE 'net synchronisation time stamp AIallowed
AS _BYTE 'AI players in netgame allowed=1 autostart_set
AS INTEGER 'game autostart setting in seconds; 0=off autostart_timeleft
AS SINGLE 'actual time to autostart the game in seconds winscore
AS _BYTE 'score to win a match
TYPE gula
'ball type (cca 90B) vi
AS vektor
'desired velocity a
AS vektor
'acceleration riadena
AS INTEGER 'is actually player controllable (0 or 1) complayer
AS INTEGER 'is computer player's ball (0 or 1) protivnik
AS INTEGER 'actual ball's enemy ball id strat
AS INTEGER 'balls behaviour strategy id freezedtime
AS INTEGER 'actual time to unfreeze players control smer_odchyl
AS SINGLE 'actual deviance from intended direction in radians klucka_time
AS INTEGER 'actual time to start doging klucka_uhol
AS SINGLE 'actual dodge angle klucka_trvanie
AS INTEGER 'actual dodge duration boost_time
AS INTEGER 'actual time to boost allowed again boost_trvanie
AS INTEGER 'actual time to end boost reactdrop_time
AS INTEGER 'actual time to start reaction drop in frames reactdrop_dur
AS INTEGER 'actual time to stop reaction drop in frames boostintended
AS INTEGER 'intention to boost or not (1, 0) syncstr
AS STRING * 3 'net synchronisation string code synctime
AS DOUBLE 'net synchronisation time stamp
TYPE tstrat
'balls behaviour strategy type okraj
AS INTEGER 'distance from screen border to turn okraj_rot
AS SINGLE 'distance from screen border to turn chybasmeru
AS SINGLE 'percentage of deviance from desired direction -- not used currently react_lag
AS INTEGER 'average reaction time in frames klucka_avgtm
AS SINGLE 'average time between dodging in fps +-50% klucka_uhol
AS SINGLE 'average dodge angle klucka_trvanie
AS INTEGER 'average dodge time +-50% klucka_uholodch
AS SINGLE 'dodge angle deviation percentage detekcia_sin
AS SINGLE 'sinus of frontal enemy detection angle detekcia_vzdfull
AS SINGLE 'distance of frontal enemy full detection detekcia_vzdmin
AS SINGLE 'distance of frontal enemy minimum detection detekcia_rot
AS SINGLE 'amount of rotation on enemy detection in radians reactdrop_per
AS INTEGER 'average reaction drop period in frames reactdrop_dur
AS INTEGER 'average reaction drop duration in frames boost_rate
AS SINGLE 'inclination to use boost in percent boost_dist
AS SINGLE 'enemy distance activating boost deciding boost_chasesin
AS SINGLE 'max. sinus of enemy to player velocity angle to apply chasing boost mate_cosenmax
AS SINGLE 'max. cosinus of (player-enemy vector to player velocity) to rotate to mate mate_rot
AS SINGLE 'amount of unit rotation towards nearest mate in rad per frame mate_en_distmin
AS SINGLE 'min. distance from enemy to apply rotation towards mate mate_distmin
AS SINGLE 'min. distance from mate to apply rotation towards mate adrenalin_rate
AS SINGLE 'percentage of reaction time improved in adrenalin mode adrenalin_energy
AS SINGLE 'energy level precentage starting adrenalin mode
klavesy
AS _BYTE 'players control keys set index clientid
AS _BYTE 'index of hosted client, 0 if local player isready
AS _BYTE '1=player is ready for game start
TYPE tklavesy
'players controller type devid
AS INTEGER 'controllers device id (0=unused) typ
AS _BYTE 'type of controller (0=unused, 1=keyboard, 2=mouse reserved, 3=gamepad, 4=AI, 5=network, 6=empty) nazov
AS STRING * 25 'game controllers name down
AS LONG 'keyp code for down right
AS LONG 'key code for right left
AS LONG 'key code for left shoota
AS LONG 'keyborad key code or gamepad button id shootb
AS LONG 'keyborad key code or gamepad button id xaxis
AS _BYTE 'gamepad analog x-asis id yaxis
AS _BYTE 'gamepad analog y-asis id dxaxis
AS _BYTE 'gamepad digital x-asis id dyaxis
AS _BYTE 'gamepad digital y-asis id isup
AS _BYTE 'controllers actual state for up isdown
AS _BYTE 'controllers actual state for down isright
AS _BYTE 'controllers actual state for right isleft
AS _BYTE 'controllers actual state for left isshoota
AS _BYTE 'controllers actual state for fire 1 isshootb
AS _BYTE 'controllers actual state for fire 2 gvektor
AS vektor
'controllers actual x and y axis state buttonstate
AS LONG 'all gamepads buttons cumulative state value buttonstatechanged
AS _BYTE '0 if no button state change, 1 if any button state changed syncstr
AS STRING * 3 'net synchronisation string code synctime
AS DOUBLE 'net synchronisation time stamp
title
AS STRING * 10 'menu title use for nothing item_height
AS INTEGER 'menu item height in pixels cursor_xpos
AS INTEGER 'x position of cursors left side cursor_width
AS INTEGER 'cursor width in pixels menucode
AS INTEGER 'stores code of selected action upon active menuitem playercode
AS INTEGER 'stores player id of active menuitem
clientid
AS INTEGER 'client origin of message text
AS STRING * MSG_LEN_MAX
'message text distribute
AS INTEGER 'message dsitribution status 1=distribute syncstr
AS STRING * 3 'net synchronisation string code synctime
AS DOUBLE 'net synchronisation time stamp
TYPE tgamesession
'my game session properties isnetgame
AS _BYTE 'network game flag; 1=network, 0=local clientid
AS INTEGER 'my client's id registered at host host_ip
AS STRING * 100 'host's ip to connect as a client host_port
AS LONG 'host's port to connect as a client get_item
AS STRING * 3 'actual item to get from host get_time
AS DOUBLE 'time of last succesfull reading from host get_isdesync
AS INTEGER 'net transfer is desynced=1 pocetgamepadov
AS INTEGER 'number of gamepads detected pocetkontrolerov
AS INTEGER 'number of game controllers printdebug
AS INTEGER 'debug mode flag (0 or 1) msgcount
AS INTEGER 'total number of actual messages newmsg
AS INTEGER 'is new messages to distribute flag msgtext
AS STRING * MSG_LEN_MAX
'message text being actually written autostart_time
AS SINGLE 'local host time of game autostart timer_pballs
AS SINGLE 'local time of last player balls update from host sync_stats
AS _BYTE 'send statistics to clients flag show_stats
AS _BYTE 'display match statistics
TYPE tclient
'hosted client type conn
AS INTEGER 'connection handle of hosted client get_item
AS STRING * 3 'next item to get from client get_time
AS DOUBLE 'time of last succesfull reading from client get_isdesync
AS INTEGER 'net desynchronisation flag host cannot get from client isdesynced
AS _BYTE 'client side is desynced - cannot get from host spectating
AS _BYTE 'client player control enabled
synctime
AS DOUBLE 'net synchronisation time stamp itemstr
AS STRING * 3 'code of the next item to get isdesync
AS _BYTE '1=the other side is desynced
'-----global variables-------------------------------------------------------------------------------------------------------------------------------
DIM SHARED klav
(1 TO PLAYER_COUNT_MAX
) AS tklavesy
'keyboard control sets DIM SHARED strat
(1 TO STRAT_COUNT_MAX
) AS tstrat
'computer players strategies
REDIM SHARED ibal
(1 TO POCET_GUL_MAX
) AS gula
'nonplayer balls transfer array REDIM SHARED ipbal
(1 TO PLAYER_NET_MAX
) AS gula
'players balls transfer array DIM SHARED iklav
(1 TO PLAYER_COUNT_MAX
) AS tklavesy
'keyboard control sets transfer array DIM SHARED istav
AS tstav
'game world state transfer array DIM SHARED ihrac
(1 TO PLAYER_NET_MAX
) AS thrac
'players balls transfer array DIM SHARED isync
AS tsyncvar
'net sync variable transfer array
'----main program------------------------------------------------------------------------------------------------------------------------------------
SetGlobalParameters
SetUpControllers
IF game.pocetgamepadov
> 0 THEN hrac
(1).klavesy
= game.pocetkontrolerov
'set gamepad as default controller for player1
AddMessage "Welcome in the Tag game.", MSG_COL, 5, 0
AddMessage "To display/hide match statistics press 'c' while gameplay.", MSG_COL, 8, 0
AddMessage "Default TCP port for the network game is 7432. ", MSG_COL, 11, 0
'--------Main menu begin---------------------------------------------------------------------------------------------------------------------------------------------------------------------
REDIM SHARED ibal
(1 TO POCET_GUL_MAX
) AS gula
'nonplayer balls transfer array REDIM SHARED ipbal
(1 TO PLAYER_NET_MAX
) AS gula
'players balls transfer array
stav.gameplay = 0
vys = FONT_H
sir = FONT_W
menu.items_count = 27
WINDOW (0, 0)-(game.maxx
, game.maxy
) IF game.hosth
<> 0 THEN hoststat
= "host started" ELSE hoststat
= "" IF game.clienth
<> 0 AND game.clientid
= 0 THEN joinstat
= "joining game... " IF game.clienth
<> 0 AND game.clientid
<> 0 THEN joinstat
= "connected to " + LEFT$(game.host_ip
, 30) IF game.clienth
= 0 AND game.clientid
= 0 THEN joinstat
= "" ReadyPlayersCount = 0
playerst(i) = ""
IF hrac
(i
).clientid
> 0 THEN playerst
(i
) = " state: connected" ELSE playerst
(i
) = " state: " IF klav
(hrac
(i
).klavesy
).typ
<= 3 THEN playerst
(i
) = " state: local player" IF hrac
(i
).isready
= 1 AND hrac
(i
).clientid
> 0 THEN playerst
(i
) = RTRIM$(playerst
(i
)) + " / ready!": ReadyPlayersCount
= ReadyPlayersCount
+ 1
IF stav.autostart_set
= 0 THEN autostart = "Off"
HumanPlayers = HumanPlayersCount
IF game.autostart_time
- stav.autostart_set
> TIMER THEN game.autostart_time
= game.autostart_time
- 86399 IF (game.isnetgame
= 0 OR (game.isnetgame
= 1 AND game.hosth
<> 0)) THEN stav.autostart_timeleft
= game.autostart_time
- TIMER IF (game.isnetgame
= 0 OR (game.isnetgame
= 1 AND game.hosth
<> 0)) AND game.autostart_time
<= TIMER THEN IF stav.AIallowed
= 1 OR (stav.AIallowed
= 0 AND HumanPlayers
>= 2) THEN game.start = 1
game.autostart_time
= TIMER + stav.autostart_set
IF game.isnetgame
= 1 AND game.hosth
<> 0 AND ReadyPlayersCount
= HumanPlayers
AND ((stav.AIallowed
= 1 AND HumanPlayers
>= 1) OR (stav.AIallowed
= 0 AND HumanPlayers
>= 2)) THEN game.start
= 1
IF stav.AIallowed
= 1 THEN AIplayers
= "Yes" ELSE AIplayers
= "No"
DisplayMessages
PrintMenuItem -2, menu, 0, 0, 0, "Tag! v.2", 0, 0, -3, 13
PrintMenuItem -1, menu, 0, 0, 0, "created in QuickBasic64 by Daniel Janec (2019) build " + MENU_BUILDSTR, 0, 0, -2, 20
PrintMenuItem 1, menu, 6, 0, 0, "Play <Space>", 0, 0, 0, MENUITEM_COLOR
PrintMenuItem
2, menu
, 1, 0, 0, "Refresh gamepads detected: " + STR$(game.pocetgamepadov
), 0, 0, 0, MENUITEM_COLOR
PrintMenuItem
3, menu
, 2, 1, 1, hrac
(1).meno
+ " controls: " + klav
(hrac
(1).klavesy
).nazov
+ RTRIM$(playerst
(1)), 150, -10 * sir
, 1, hrac
(1).col
PrintMenuItem
4, menu
, 3, 1, 1, " color:" + STR$(hrac
(1).col
), 150, -10 * sir
, 1, hrac
(1).col
PrintMenuItem
5, menu
, 2, 2, 1, hrac
(2).meno
+ " controls: " + klav
(hrac
(2).klavesy
).nazov
+ RTRIM$(playerst
(2)), 150, -10 * sir
, 1, hrac
(2).col
PrintMenuItem
6, menu
, 3, 2, 1, " color:" + STR$(hrac
(2).col
), 150, -10 * sir
, 1, hrac
(2).col
PrintMenuItem
7, menu
, 2, 3, 1, hrac
(3).meno
+ " controls: " + klav
(hrac
(3).klavesy
).nazov
+ RTRIM$(playerst
(3)), 150, -10 * sir
, 1, hrac
(3).col
PrintMenuItem
8, menu
, 3, 3, 1, " color:" + STR$(hrac
(3).col
), 150, -10 * sir
, 1, hrac
(3).col
PrintMenuItem
9, menu
, 2, 4, 1, hrac
(4).meno
+ " controls: " + klav
(hrac
(4).klavesy
).nazov
+ RTRIM$(playerst
(4)), 150, -10 * sir
, 1, hrac
(4).col
PrintMenuItem
10, menu
, 3, 4, 1, " color:" + STR$(hrac
(4).col
), 150, -10 * sir
, 1, hrac
(4).col
PrintMenuItem
11, menu
, 2, 5, 1, hrac
(5).meno
+ " controls: " + klav
(hrac
(5).klavesy
).nazov
+ RTRIM$(playerst
(5)), 150, -10 * sir
, 1, hrac
(5).col
PrintMenuItem
12, menu
, 3, 5, 1, " color:" + STR$(hrac
(5).col
), 150, -10 * sir
, 1, hrac
(5).col
PrintMenuItem
13, menu
, 2, 6, 1, hrac
(6).meno
+ " controls: " + klav
(hrac
(6).klavesy
).nazov
+ RTRIM$(playerst
(6)), 150, -10 * sir
, 1, hrac
(6).col
PrintMenuItem
14, menu
, 3, 6, 1, " color:" + STR$(hrac
(6).col
), 150, -10 * sir
, 1, hrac
(6).col
PrintMenuItem
15, menu
, 2, 7, 1, hrac
(7).meno
+ " controls: " + klav
(hrac
(7).klavesy
).nazov
+ RTRIM$(playerst
(7)), 150, -10 * sir
, 1, hrac
(7).col
PrintMenuItem
16, menu
, 3, 7, 1, " color:" + STR$(hrac
(7).col
), 150, -10 * sir
, 1, hrac
(7).col
PrintMenuItem
17, menu
, 2, 8, 1, hrac
(8).meno
+ " controls: " + klav
(hrac
(8).klavesy
).nazov
+ RTRIM$(playerst
(8)), 150, -10 * sir
, 1, hrac
(8).col
PrintMenuItem
18, menu
, 3, 8, 1, " color:" + STR$(hrac
(8).col
), 150, -10 * sir
, 1, hrac
(8).col
PrintMenuItem
19, menu
, 8, 0, 1, "Player starting energy: " + LTRIM$(STR$(stav.energy_player_start
)), 100, -10 * sir
, 2, MENUITEM_COLOR
PrintMenuItem
20, menu
, 4, 0, 1, " Number of players: " + LTRIM$(STR$(stav.pocethracov
)), 100, -10 * sir
, 2, MENUITEM_COLOR
PrintMenuItem 21, menu, 12, 0, 1, " CPU players allowed: " + AIplayers, 100, -10 * sir, 2, MENUITEM_COLOR
PrintMenuItem
22, menu
, 5, 0, 1, " Balls count: " + LTRIM$(STR$(stav.pocetgulzvoleny
)), 100, -10 * sir
, 2, MENUITEM_COLOR
PrintMenuItem
23, menu
, 13, 0, 1, " Match winning score: " + LTRIM$(STR$(stav.winscore
)), 100, -10 * sir
, 2, MENUITEM_COLOR
PrintMenuItem 24, menu, 11, 0, 1, " Game autostart: " + autostart, 100, -10 * sir, 2, MENUITEM_COLOR
PrintMenuItem 25, menu, 9, 0, 0, " Host game: " + hoststat, 100, -10 * sir, 2, MENUITEM_COLOR
PrintMenuItem 26, menu, 10, 0, 0, " Join game: " + joinstat, 100, -10 * sir, 2, MENUITEM_COLOR
PrintMenuItem 27, menu, 7, 0, 0, "Exit <Esc>", 0, 0, 2, MENUITEM_COLOR
PrintMenuCursor menu
IF game.msgwrite
= 1 AND game.isnetgame
= 1 THEN WriteMessage k: k
= 0 IF game.msgwrite
= 0 AND game.isnetgame
= 1 THEN WriteMessage
-1
'---debug code begin---------------------------------------------
IF k
= 98 THEN game.printdebug
= -(game.printdebug
= 0) IF game.printdebug
= 1 THEN DebugScreen k
'print debug info on screen '---debug code end-----------------------------------------------
FOR i
= 1 TO game.pocetkontrolerov
ReadGamepad klav(i)
IF klav
(i
).buttonstatechanged
THEN IF klav
(i
).isshoota
THEN k
= 13: klav
(i
).isshoota
= 0 IF klav
(i
).isup
THEN k
= 18432: klav
(i
).isup
= 0 IF klav
(i
).isdown
THEN k
= 20480: klav
(i
).isdown
= 0 IF klav
(i
).isright
THEN k
= 19712: klav
(i
).isright
= 0 IF klav
(i
).isleft
THEN k
= 19200: klav
(i
).isleft
= 0
IF menu.item_active
> 1 THEN menu.item_active
= menu.item_active
- 1 IF menu.item_active
< menu.items_count
THEN menu.item_active
= menu.item_active
+ 1 CASE 2 'players controller i = menu.playercode
hrac(i).klavesy = hrac(i).klavesy - 1
IF hrac
(i
).klavesy
< PLAYER_NET_MAX
+ 1 THEN hrac
(i
).klavesy
= PLAYER_NET_MAX
+ 1 i = menu.playercode
hrac(i).col = hrac(i).col - 1
IF hrac
(i
).col
< 1 THEN hrac
(i
).col
= stav.maxcol
stav.pocethracov = stav.pocethracov - 1
IF stav.pocetgulzvoleny
> 0 THEN stav.pocetgulzvoleny = stav.pocetgulzvoleny - 1
IF stav.energy_player_start
> 10 THEN stav.energy_player_start = stav.energy_player_start - 1
IF stav.autostart_set
> 0 THEN stav.autostart_set = stav.autostart_set - 10
game.autostart_time
= TIMER + stav.autostart_set
CASE 12 'CPU players allowed stav.AIallowed = 0
IF stav.winscore
> 1 THEN stav.winscore
= stav.winscore
- 1 CASE 2 'players controller i = menu.playercode
hrac(i).klavesy = hrac(i).klavesy + 1
IF hrac
(i
).klavesy
> game.pocetkontrolerov
THEN hrac
(i
).klavesy
= game.pocetkontrolerov
i = menu.playercode
hrac(i).col = hrac(i).col + 1
IF hrac
(i
).col
> stav.maxcol
THEN hrac
(i
).col
= 1 IF stav.pocethracov
< PLAYER_COUNT_MAX
THEN stav.pocethracov = stav.pocethracov + 1
IF stav.pocetgulzvoleny
< POCET_GUL_MAX
THEN stav.pocetgulzvoleny = stav.pocetgulzvoleny + 1
IF stav.energy_player_start
< ENERGY_PLAYER_MAX
THEN stav.energy_player_start = stav.energy_player_start + 1
IF stav.autostart_set
< AUTOSTART_SEC_MAX
THEN stav.autostart_set = stav.autostart_set + 10
game.autostart_time
= TIMER + stav.autostart_set
CASE 12 'CPU players allowed stav.AIallowed = 1
IF stav.winscore
< 99 THEN stav.winscore
= stav.winscore
+ 1 SetUpControllers
newenergy
= LTRIM$(STR$(stav.energy_player_start
)) newenergy = InputText$(newenergy, menu.cursor_xpos + 2 * sir, menu.ypos + (menu.item_active - 1) * menu.item_height, MENUITEM_COLOR, 48, "<Type starting energy>", 0, 1)
energyval
= VAL(newenergy
) IF energyval
< 10 THEN energyval
= 10 IF energyval
> ENERGY_PLAYER_MAX
THEN energyval
= ENERGY_PLAYER_MAX
stav.energy_player_start = energyval
novemeno$ = InputText$(hrac(menu.playercode).meno, menu.cursor_xpos + 2 * sir, menu.ypos + (menu.item_active - 1) * menu.item_height, hrac(menu.playercode).col, 14, "<Type name>", 0, 0)
IF novemeno$
<> CHR$(27) AND LEN(novemeno$
) > 0 THEN hrac
(menu.playercode
).meno
= novemeno$
HostGame
gethostip$
= InputText$
(game.host_ip
, menu.cursor_xpos
+ 2 * sir
, menu.ypos
+ (menu.item_active
- 1) * menu.item_height
, MENUITEM_COLOR
, LEN(game.host_ip
), "<Type IP address or host name>", 1, 0) IF gethostip$
<> CHR$(27) THEN game.host_ip
= gethostip$
ResetNetGame
IF game.clientid
> 0 THEN hrac
(game.clientid
).isready
= 1 - hrac
(game.clientid
).isready
IF (game.isnetgame
= 0 OR (game.isnetgame
= 1 AND game.hosth
<> 0)) AND (stav.AIallowed
= 1 OR (stav.AIallowed
= 0 AND HumanPlayersCount
>= 2)) THEN game.start
= 1 game.exituj = 1
CASE 116 'messaage write mode on game.msgwrite = 1
k = 0
IF game.clientid
> 0 THEN hrac
(game.clientid
).isready
= 1 - hrac
(game.clientid
).isready
IF (game.isnetgame
= 0 OR (game.isnetgame
= 1 AND game.hosth
<> 0)) AND (stav.AIallowed
= 1 OR (stav.AIallowed
= 0 AND HumanPlayersCount
>= 2)) THEN game.start
= 1 game.exituj = 1
FOR i
= 1 TO PLAYER_COUNT_MAX
'set AI controller type for computer players IF game.isnetgame
= 1 AND game.clienth
<> 0 AND game.clientid
<> 0 AND klav
(hrac
(i
).klavesy
).typ
= 4 THEN hrac
(i
).klavesy
= hrac
(i
).klavesy
+ 1 'change AI controler on client to keyboard IF (game.isnetgame
= 0 OR (game.isnetgame
= 1 AND game.hosth
<> 0)) AND klav
(hrac
(i
).klavesy
).typ
= 4 THEN 'on host or singleplayer change AI controlled ball bal(hrac(i).bal).complayer = 1
bal(hrac(i).bal).complayer = 0
IF game.isnetgame
AND stav.pocethracov
> PLAYER_NET_MAX
THEN stav.pocethracov
= PLAYER_NET_MAX
IF menu.menucode
= 4 AND (k
= 19712 OR k
= 19200) THEN 'after changing players count stav.energy_player_start
= INT(stav.energy_allmin
/ stav.pocethracov
) 'calculate players energy IF stav.energy_player_start
< stav.energy_playermin
THEN stav.energy_player_start
= stav.energy_playermin
IF stav.energy_player_start
> stav.energy_playermax
THEN stav.energy_player_start
= stav.energy_playermax
IF game.isnetgame
= 1 AND game.clienth
<> 0 AND game.clientid
> 0 AND stav.gameplay
= 1 THEN game.start
= 1 IF game.isnetgame
= 1 THEN SyncNetGameData
game.start = 0
IF game.clientid
> 0 THEN hrac
(game.clientid
).isready
= 0 '--------end of main menu---------------------------------------------------------------------------------------------------------------------------------------------------------------------
'----------------------------------new game start-------------------------------------------------------------------------------------------------
WINDOW (0, 0)-(stav.maxx
, stav.maxy
) IF game.exituj
<> 1 THEN 'new game starts here '----------------------------------set the world on the new game start-------------------------------
IF game.hosth
<> 0 THEN AddMessage
"The match has been started by the host. Whoever scores" + RTRIM$(STR$(stav.winscore
)) + " times wins.", MSG_COL
, MSG_DUR_STD
, 1
FOR i
= 1 TO PLAYER_NET_MAX
FOR j
= 1 TO PLAYER_NET_MAX
stats(i, j) = 0
stav.gameplay = 1
stav.pocetgul = stav.pocetgulzvoleny + stav.pocethracov
stav.pocetgulx
= MATHROUND
(SQR(4 / 3 * stav.pocetgul
)) IF stav.pocetgulx
< stav.pocethracov
THEN stav.pocetgulx
= stav.pocethracov
stav.pocetguly
= _CEIL(stav.pocetgul
/ stav.pocetgulx
)
IF stav.pocethracov
< 2 THEN stav.pocethracov
= 2 FOR i
= 1 TO stav.pocethracov
hrac(i).skore = 0
FOR n
= 1 TO stav.pocethracov: bal
(n
).syncstr
= GETITEM_PBAL: bal
(n
).synctime
= 0:
NEXT n
FOR n
= stav.pocethracov
+ 1 TO UBOUND(bal
): bal
(n
).syncstr
= GETITEM_BAL: bal
(n
).synctime
= 0:
NEXT n
stav.zacinabal
= hrac
(INT(RND * stav.pocethracov
+ 1)).bal
DO 'new round starts here '-------------------------------set the world on the new round start---------------------------
stav.koniec_kola = 0
stav.pauza = 0
stav.vitaz = 0
game.exituj = 0
stav.baljeto = 0
IF game.isnetgame
= 1 AND game.hosth
<> 0 THEN 'engage new spectating players FOR i
= 2 TO stav.pocethracov
IF client
(i
).spectating
= 1 THEN hrac(i).skore = 0
bal(hrac(i).bal).hrac = i
bal(hrac(i).bal).complayer = 0
bal(hrac(i).bal).riadena = 1
client(i).spectating = 0
bal(i).vi.x = 0: bal(i).vi.y = 0
FOR j
= 1 TO PLAYER_NET_MAX
stats(i, j) = 0
stats(j, i) = 0
coloffset
= 104 + INT(RND * 10) colcoef
= (1 + INT(RND * (246 - coloffset
))) / stav.pocetgulx
FOR i
= 1 TO stav.pocetguly
+ 1 'set all balls FOR j
= 1 TO stav.pocetgulx
n = (i - 1) * stav.pocetgulx + j:
ry
= 20 + RND * INT(((stav.maxy
- 100) / (stav.pocetguly
+ 1) - 25) / 2) rx
= 10 + RND * INT(((stav.maxx
- 100) / (stav.pocetgulx
+ 1) - 25) / 2) bcol = coloffset + j * colcoef
bal(n).i = n
bal(n).col = bcol
bal
(n
).x
= 100 + j
* INT((stav.maxx
- 100) / (stav.pocetgulx
+ 1)) bal
(n
).y
= 100 + i
* INT((stav.maxy
- 100) / (stav.pocetguly
+ 1)) bal(n).r = rx * -(rx < ry) + ry * -(ry < rx)
bal(n).m = 4 / 4 * pi * bal(n).r ^ 2
bal(n).v.x = -10 / FPS: bal(n).v.y = -30 / FPS
bal(n).a.x = ACC_X * stav.maxx / RES_X_TARG
bal(n).a.y = ACC_Y * stav.maxx / RES_X_TARG
bal
(n
).vi.x
= -(bal
(n
).complayer
= 1) * RND * stav.vmax
- stav.vmax
/ 2 bal
(n
).vi.y
= -(bal
(n
).complayer
= 1) * RND * stav.vmax
- stav.vmax
/ 2 bal(n).riadena = 0
bal(n).energia = stav.energy_player_start
bal(n).freezedtime = 0: bal(n).klucka_time = 0: bal(n).klucka_pocet = 0
bal(n).klucka_trvanie = 0: bal(n).klucka_uhol = 0
bal(n).boost_time = 0: bal(n).boost_trvanie = 0
bal(n).synctime = 0
'---set players balls default atributtes--------------------------------------------------------
FOR i
= 1 TO stav.pocethracov
hrac(i).bal = i
bal(hrac(i).bal).hrac = i
bal(hrac(i).bal).riadena = 1
IF stav.AIallowed
= 0 AND klav
(hrac
(i
).klavesy
).typ
= 4 THEN bal(hrac(i).bal).energia = 0
bal(hrac(i).bal).riadena = 0
bal(hrac(i).bal).r = PLAY_BALL_R * stav.maxx / RES_X_TARG
bal(hrac(i).bal).m = 4 / 4 * pi * PLAY_BALL_R ^ 2 / 2 'Players have only half density
bal(hrac(i).bal).col = hrac(i).col
bal(hrac(i).bal).strat = 3
'---decide initially tagged player-------------------------------------------------------------
zacinalNaposledyBal = stav.zacinabal
stav.balbudeto = stav.zacinabal
stav.zacinabal = stav.zacinabal + 1
IF stav.zacinabal
> stav.pocetgulx
THEN stav.zacinabal
= 1 stav.baljeto = stav.zacinabal
FOR b
= 1 TO stav.pocethracov
bal(hrac(b).bal).protivnik = stav.baljeto * -(hrac(b).bal <> stav.baljeto)
bal(stav.zacinabal).protivnik = zacinalNaposledyBal
'----------------------------------game action loop--------------------------------------------
game.tstart
= TIMER(.001) IF k
= 116 AND game.clientid
> 0 AND game.msgwrite
= 0 THEN game.msgwrite
= 1: k
= 0 'message writing mode IF game.msgwrite
= 1 THEN WriteMessage k: k
= 0 IF NOT (game.isnetgame
= 1 AND game.clienth
<> 0) AND (k
= 112 OR k
= 102) THEN stav.pauza
= 1 - stav.pauza
DrawScore 'Draw players score on screen
DisplayMessages 'Draw messages
'---debug code begin---------------------------------------------
IF k
= 98 THEN game.printdebug
= -(game.printdebug
= 0) IF game.printdebug
= 1 THEN DebugScreen k
'display debug info on screen '---debug code end-----------------------------------------------
IF k
= 99 THEN game.show_stats
= -(game.show_stats
= 0) IF game.show_stats
= 1 THEN DisplayStatistics
'display match statistics
FOR i
= 1 TO stav.pocethracov
ResolvePlayerControl bal(hrac(i).bal), klav(hrac(i).klavesy) 'resolve players control
IF bal
(hrac
(i
).bal
).riadena
= 1 THEN CalculatePlayerState bal(hrac(i).bal) 'calculate player status
FOR n
= 1 TO stav.pocetgul
PerformMovement bal(n) 'do ball movement
FOR i
= 1 TO stav.pocetgul
FOR j
= i
+ 1 TO stav.pocetgul
BounceTest bal(i), bal(j) 'Test balls bounce
PauseGame
IF game.isnetgame
= 1 THEN SyncNetGameData
FOR n
= 1 TO stav.pocetgul
DrawBall bal(n) 'draw ball
IF stav.vitaz
<> 0 THEN DrawWinScreen
IF NOT (game.isnetgame
= 1 AND game.clienth
<> 0) AND (k
= 102) THEN stav.pauza
= 1 IF k
= 27 AND game.isnetgame
= 1 THEN AddMessage
"To quit network game press 't' and type '/q'", MSG_COL
, MSG_DUR_STD
, 0: k
= 0 IF k
= 27 AND game.isnetgame
= 0 THEN stav.koniec_kola
= 2
CalculateFps
'---------------------------end of game action loop---------------------------------------------
anyHumanPlayer = HumanPlayersCount
resumegame = 0
DO 'wait for resume if not net game IF k
= 27 AND game.hosth
= 0 THEN stav.koniec_kola
= 2 FOR i
= 1 TO stav.pocethracov
IF klav
(hrac
(i
).klavesy
).typ
= 3 THEN ReadGamepad klav
(hrac
(i
).klavesy
) IF klav
(hrac
(i
).klavesy
).isshoota
THEN resumegame
= 1 IF klav
(hrac
(i
).klavesy
).isshootb
THEN stav.koniec_kola
= 2 LOOP UNTIL (resumegame
= 1) OR (anyHumanPlayer
= 0) OR (stav.koniec_kola
= 2) OR (game.isnetgame
= 1) '---------------------------end of round-----------------------------------------------------------
LOOP UNTIL stav.koniec_kola
= 2 OR (stav.AIallowed
= 0 AND anyHumanPlayer
< 2) IF (stav.AIallowed
= 0 AND anyHumanPlayer
< 2) THEN AddMessage
"Match was ended for less than 2 players left", MSG_COL
, MSG_DUR_STD
, 0 '---------------------------end of game------------------------------------------------------------
game.autostart_time
= TIMER + stav.autostart_set
'---------------------------end of program------------------------------------------------------------
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
'----------------------------------------------------------------------------------------------------------------------------------------------------
IF hrac
(stav.vitaz
).skore
>= stav.winscore
THEN windelay
= DELAY_MATCHEND
ELSE windelay
= DELAY_ROUNDSTART
IF game.autostart_time
- windelay
> TIMER THEN game.autostart_time
= game.autostart_time
- 86399 IF (game.autostart_time
<= TIMER) AND (game.isnetgame
= 0 OR game.hosth
<> 0) THEN stav.koniec_kola = 1 'end of round
IF hrac
(stav.vitaz
).skore
>= stav.winscore
THEN stav.koniec_kola
= 2 'end of match either IF (game.isnetgame
= 0 OR game.hosth
<> 0) THEN stav.autostart_timeleft
= game.autostart_time
- TIMER IF hrac
(stav.vitaz
).skore
< stav.winscore
THEN winstr1$
= "....and the winner of this round is... " + RTRIM$(hrac
(stav.vitaz
).meno
) + timeleft$
winstr2$ = "Press <fire> for the next round"
winstr1$
= "...>>> " + RTRIM$(hrac
(stav.vitaz
).meno
) + " <<<.... scores " + LTRIM$(STR$(stav.winscore
)) + " and becomes the MATCH WINNER!" + timeleft$
winstr2$ = "Press <fire> to return to the menu"
DisplayStatistics
COLOR bal
(hrac
(stav.vitaz
).bal
).col
_PRINTSTRING ((game.maxx
- LEN(winstr1$
) * 10) / 2, (game.maxy
- 50) / 2), winstr1$
IF stav.koniec_kola
> 0 THEN _PRINTSTRING ((game.maxx
- LEN(winstr2$
) * 10) / 2, (game.maxy
- 50) / 2 + 50), winstr2$
'----------------------------------------------------------------------------------------------------------------------------------------------------
IF stav.pocethracov
<= PLAYER_NET_MAX
THEN playercount
= stav.pocethracov
ELSE playercount
= PLAYER_NET_MAX
PRINT "Match statistics - tags given by player" tagsum = 0
LOCATE row
+ 2 + i
, col
+ j
* 11 tagsum = tagsum + stats(i, j)
LOCATE row
+ 2 + i
, col
+ j
* 11
'----------------------------------------------------------------------------------------------------------------------------------------------------
FUNCTION HumanPlayersCount
'set pre-game parameters HumanPlayersCount = 0
FOR i
= 1 TO stav.pocethracov
IF bal
(hrac
(i
).bal
).complayer
= 0 THEN HumanPlayersCount
= HumanPlayersCount
+ 1
'----------------------------------------------------------------------------------------------------------------------------------------------------
SUB SetGlobalParameters
'set pre-game parameters '-------------------------------set game session parameters----------------------------------------------------------------------------------------
game.fpsactual = FPS
game.isnetgame = 0
game.clienth = 0
game.clientid = 0
game.hosth = 0
game.host_port = HOSTPORT_DEFAULT
game.host_ip = HOSTIP_DEFAULT
game.printdebug = DEBUGMODE
game.exituj = 0
game.start = 0
game.newmsg = 0
game.msgcount = 0
game.msgwrite = 0
game.msgtext = ""
game.show_stats = 0
sync.syncstr = GETITEM_SYNC
sync.synctime = 0
'-------------------------------set game world parameters----------------------------------------------------------------------------------------
stav.syncstr = GETITEM_STAV
stav.synctime = 0
stav.pauza = 0
stav.gameplay = 0
stav.fps = FPS
stav.pocethracov = PLAYER_COUNT_INI
stav.pocetgulzvoleny = POCET_GUL_INI
stav.pocetgul = POCET_GUL_INI
stav.energy_allmin = ENERGY_ALL_MIN
stav.energy_playermin = ENERGY_PLAYER_MIN
stav.energy_playermax = ENERGY_PLAYER_MAX
stav.energydec = ENERGY_DEC
stav.odpor = FRICTION
stav.minx = 0
stav.miny = 0
stav.maxx = RES_X_TARG
stav.maxy = RES_Y_TARG
stav.vmax = V_MAX * stav.maxx / RES_X_TARG
stav.maxcol = MAX_COL
stav.boostallowed = 1
stav.massallowed = 0 'sticky balls problem if mass allowed unsolved yet
stav.autostart_set = 0
game.autostart_time = 0
stav.AIallowed = 1
stav.winscore = 3
stav.energy_player_start = (stav.energy_allmin / stav.pocethracov) 'calculate players energy
IF stav.energy_player_start
< stav.energy_playermin
THEN stav.energy_player_start
= stav.energy_playermin
IF stav.energy_player_start
> stav.energy_playermax
THEN stav.energy_player_start
= stav.energy_playermax
stats
(PLAYER_NET_MAX
+ 1, 1) = ASC(GETITEM_STAT
, 1) stats
(PLAYER_NET_MAX
+ 1, 2) = ASC(GETITEM_STAT
, 2) stats
(PLAYER_NET_MAX
+ 1, 3) = ASC(GETITEM_STAT
, 3)
'-------------------------------set game controllers---------------------------------------------------------------------------------------------
FOR i
= 1 TO UBOUND(klav
) 'set all the other game controllers as unused, few reserved for net players klav(i).typ = 5
klav(i).typ = 0
klav(i).devid = 0
klav(i).syncstr = GETITEM_KLAV
klav(i).synctime = 0
'set default controllers
kid = PLAYER_NET_MAX + 1 'CPU void controller
klav(kid).id = kid: klav(kid).devid = 1: klav(kid).nazov = "<CPU>": klav(kid).typ = 4
kid = PLAYER_NET_MAX + 2 'keyboard set 1 controller
klav(kid).id = kid: klav(kid).devid = 1: klav(kid).nazov = "<Arrow keys + LShift>": klav(kid).typ = 1
klav(kid).up = 18432: klav(kid).down = 20480: klav(kid).left = 19200: klav(kid).right = 19712
klav(kid).shoota = 100304: klav(kid).shootb = 100306
kid = PLAYER_NET_MAX + 3 'keyboard set 2 controller
klav(kid).id = kid: klav(kid).devid = 1: klav(kid).nazov = "<W,A,S,D + RShift>": klav(kid).typ = 1
klav(kid).up = 119: klav(kid).down = 115: klav(kid).left = 97: klav(kid).right = 100
klav(kid).shoota = 100303: klav(kid).shootb = 100305
kid = PLAYER_NET_MAX + 4 'keyboard set 3 controller
klav(kid).id = kid: klav(kid).devid = 1: klav(kid).nazov = "<I,J,K,L + Enter>": klav(kid).typ = 1
klav(kid).up = 105: klav(kid).down = 107: klav(kid).left = 106: klav(kid).right = 108
klav(kid).shoota = 13: klav(kid).shootb = 21248
'-------------------------------set players------------------------------------------------------------------------------------------------------
FOR i
= 1 TO UBOUND(hrac
) 'initial setting for all players hrac(i).bal = i
hrac(i).skore = 0
hrac(i).klavesy = CPU_CONTROLID
hrac(i).col = 32 + i * 3
hrac(i).clientid = 0
bal(hrac(i).bal).complayer = 1
hrac(i).syncstr = GETITEM_HRAC
hrac(i).synctime = 0
'personalize some players initially
bal(hrac(1).bal).complayer = 0
hrac(1).klavesy = PLAYER_NET_MAX + 2
hrac(1).meno = "Chuck"
hrac(2).meno = "Arnold"
hrac(3).meno = "Jean"
hrac(4).meno = "Bruce"
hrac(5).meno = "Dolph"
hrac(6).meno = "Sylvester"
hrac(7).meno = "Jet"
hrac(8).meno = "Dwayne"
'-------------------------------set behaviour strategies------------------------------------------------------------------------------------------
'some void strategy
strat(1).okraj = PRIESTOR_MIN:
strat(1).okraj_rot = 0.1
strat(1).chybasmeru = 0.00:
strat(1).klucka_avgtm = 1 * FPS: strat(1).klucka_pocet = 5
strat(1).klucka_trvanie = 0.25 * FPS: strat(1).klucka_uhol = pi / 2: strat(1).klucka_uholodch = 0.2
strat
(1).detekcia_sin
= SIN(pi
/ 4): strat
(1).detekcia_vzdfull
= 500: strat
(1).detekcia_vzdmin
= 1000: strat
(1).detekcia_rot
= 0.5 strat(1).boost_dist = 200
strat
(1).boost_chasesin
= SIN(pi
/ 8) strat(1).mate_cosenmax = -0.8 'cos(140/180*pi)
strat(1).mate_rot = 0.1 ' 3*pi /FPS
strat(1).mate_en_distmin = 5 * PLAY_BALL_R
strat(1).mate_distmin = 4 * PLAY_BALL_R
'non dodging strategy
strat(2).okraj = PRIESTOR_MIN + 10
strat(2).okraj_rot = 0.1
strat(2).chybasmeru = 0.00
strat(2).reactdrop_per = 0 * FPS
strat(2).reactdrop_dur = 0 * FPS
strat(2).klucka_avgtm = 10 * FPS
strat(2).klucka_pocet = 0
strat(2).klucka_trvanie = 0 * FPS
strat(2).klucka_uhol = 0 * pi / 3
strat(2).klucka_uholodch = 0.2
strat
(2).detekcia_sin
= SIN(pi
/ 6) strat(2).detekcia_vzdfull = 500
strat(2).detekcia_vzdmin = 1000
strat(2).detekcia_rot = 0.5
strat(2).boost_dist = 200
strat
(2).boost_chasesin
= SIN(pi
/ 8) strat(2).mate_cosenmax = -0.8 'cos(140/180*pi)
strat(2).mate_rot = 0.1 ' 3*pi /FPS
strat(2).mate_en_distmin = 5 * PLAY_BALL_R
strat(2).mate_distmin = 4 * PLAY_BALL_R
'dodging strategy - currently used for all AI players
strat(3).okraj = PRIESTOR_MIN + 10
strat(3).okraj_rot = 0.1
strat(3).chybasmeru = 0.30
strat(3).reactdrop_per = 0.8 * FPS
strat(3).reactdrop_dur = 0.4 * FPS
strat(3).klucka_avgtm = 5 * FPS
strat(3).klucka_pocet = 3
strat(3).klucka_trvanie = 2 * FPS
strat(3).klucka_uhol = pi * 2 / 3
strat(3).klucka_uholodch = 0.2
strat
(3).detekcia_sin
= SIN(pi
/ 6) strat(3).detekcia_vzdfull = 300
strat(3).detekcia_vzdmin = 1500
strat(3).detekcia_rot = 0.5 '10 * pi / FPS
strat(3).boost_dist = 200
strat
(3).boost_chasesin
= SIN(pi
/ 8) strat(3).mate_cosenmax = -0.8 'cos(140/180*pi)
strat(3).mate_rot = 0.1 ' 3*pi /FPS
strat(3).mate_en_distmin = 8 * PLAY_BALL_R
strat(3).mate_distmin = 4 * PLAY_BALL_R
strat(3).adrenalin_rate = 0.90
strat(3).adrenalin_energy = 0.30
'-------------------------------set main menu-----------------------------------------------------------------------------------------------------
menu.item_active = 1
menu.items_count = 22
menu.cursor_col = 15
menu.cursor_width = 400
menu.item_height = FONT_H + 4
menu.cursor_xpos
= INT((game.maxx
- menu.cursor_width
) / 2) menu.ypos
= INT((game.maxy
- menu.items_count
* menu.item_height
) / 2) menu.cursor_out = 5
'-------------------------------set balls---------------------------------------------------------------------------------------------------------
FOR n
= 1 TO stav.pocethracov: bal
(n
).syncstr
= GETITEM_PBAL: bal
(n
).synctime
= 0:
NEXT n
FOR n
= stav.pocethracov
+ 1 TO UBOUND(bal
): bal
(n
).syncstr
= GETITEM_BAL: bal
(n
).synctime
= 0:
NEXT n
'----------------------------------------------------------------------------------------------------------------------------------------------------
msginput_x = 10
msginput_y = RES_Y - 20
IF k
= 27 THEN game.msgwrite
= 0
_PRINTSTRING (msginput_x
, msginput_y
), "Type message>> " + tmptext
IF k
= -1 AND game.msgwrite
= 0 THEN _PRINTSTRING (msginput_x
, msginput_y
), "Press 't' to writte text message to other players" + tmptext
AddMessage tmptext, MSG_COL, MSG_DUR_STD, 0
AddMessage
RTRIM$(hrac
(game.clientid
).meno
) + "> " + tmptext
, hrac
(game.clientid
).col
, MSG_DUR_STD
, 1 game.msgwrite = 0
game.msgtext
= tmptext
+ CHR$(92)
'----------------------------------------------------------------------------------------------------------------------------------------------------
SUB SetUpControllers
'detect gamepads and set them as game controllers
FOR i
= 1 TO UBOUND(klav
) 'dispose all gamepad constrollers klav(i).typ = 0
klav(i).devid = 0
klav_volne = 1
game.pocetgamepadov = 0
klav_volne = klav_volne + 1
klav_used = klav_volne - 1
devices
= _DEVICES 'must be read prior to other device functions usage klav(klav_volne).id = klav_volne
klav(klav_volne).devid = i
klav(klav_volne).typ = 3
klav
(klav_volne
).nazov
= "<Gamepad" + LTRIM$(STR$(klav_volne
- klav_used
)) + ">" klav(klav_volne).xaxis = 1
klav(klav_volne).yaxis = 2
klav(klav_volne).shoota = 1
klav(klav_volne).shootb = 8
klav_volne = klav_volne + 1
game.pocetgamepadov = game.pocetgamepadov + 1
game.pocetkontrolerov = klav_volne - 1
'----------------------------------------------------------------------------------------------------------------------------------------------------
SUB MainMenuScreen
'perform choises in main menu
'----------------------------------------------------------------------------------------------------------------------------------------------------
'--------------------------host side---------------------------------------------------------------------------------------------------------
IF game.hosth
<> 0 THEN 'sync host data FOR i
= PLAYER_NET_MIN
TO PLAYER_NET_MAX
'for each client try to connect IF client
(i
).conn
= 0 AND i
<= stav.pocethracov
THEN client
(i
).conn
= _OPENCONNECTION(game.hosth
) 'try to open connection if not open client(i).get_item = GETITEM_SYNC
client(i).get_isdesync = 0
client
(i
).get_time
= TIMER(.001) IF client
(i
).conn
<> 0 THEN 'if connection opened client(i).spectating = 1
game.sync_stats = 1
msgtext$ = " joins the game from the next round"
client(i).spectating = 0
msgtext$ = " has joined the game"
AddMessage
"Player " + RTRIM$(hrac
(i
).meno
) + msgtext$
, MSG_COL
, MSG_DUR_STD
, 1 IF (TIMER(.001) - client
(i
).get_time
) > NET_TIMEOUT_LIMIT
AND client
(i
).conn
<> 0 THEN CloseClientConn
(i
) FOR i
= PLAYER_NET_MIN
TO PLAYER_NET_MAX
'sync data with each client sync.clientid = i
IF client
(i
).get_isdesync
= 1 THEN 'flush acquired data if desynced GET #client
(i
).conn
, , flush$
client(i).get_isdesync = 0
client(i).get_item = GETITEM_SYNC
IF client
(i
).get_item
= GETITEM_SYNC
THEN 'first get sync info on what item to get next GET #client
(i
).conn
, , isync
IF isync.syncstr
= GETITEM_SYNC
THEN client(i).get_item = isync.itemstr
client
(i
).get_time
= TIMER(.001) client(i).isdesynced = isync.isdesync
client(i).get_isdesync = 1
IF client
(i
).get_item
= GETITEM_KLAV
THEN 'get controller state from client GET #client
(i
).conn
, , clklav
IF clklav.syncstr
= GETITEM_KLAV
THEN klav(hrac(i).klavesy).isup = clklav.isup
klav(hrac(i).klavesy).isdown = clklav.isdown
klav(hrac(i).klavesy).isright = clklav.isright
klav(hrac(i).klavesy).isleft = clklav.isleft
klav(hrac(i).klavesy).isshoota = clklav.isshoota
klav(hrac(i).klavesy).isshootb = clklav.isshootb
klav(hrac(i).klavesy).gvektor = clklav.gvektor
client
(i
).get_time
= TIMER(.001) client(i).get_isdesync = 1
client(i).get_item = GETITEM_SYNC
IF client
(i
).get_item
= GETITEM_HRAC
THEN 'get client's player GET #client
(i
).conn
, , clhrac
IF clhrac.syncstr
= GETITEM_HRAC
THEN clhrac.skore = hrac(i).skore 'keep players socre
hrac(i) = clhrac 'get player data from client
hrac(i).klavesy = i 'set player net controlled
hrac(i).clientid = i 'set player's clientid
client
(i
).get_time
= TIMER(.001) client(i).get_isdesync = 1
client(i).get_item = GETITEM_SYNC
IF client
(i
).get_item
= GETITEM_MESG
THEN 'get message from client GET #client
(i
).conn
, , imsg
IF imsg.syncstr
= GETITEM_MESG
THEN AddMessage imsg.text, imsg.col, imsg.time_dur, 1
msg(game.msgcount).clientid = imsg.clientid
client
(i
).get_time
= TIMER(.001) client(i).get_isdesync = 1
client(i).get_item = GETITEM_SYNC
IF TIMER(.001) - stav.synctime
> UPDATE_PER_STAV
THEN 'check if update time sync_stav = 1
IF TIMER(.001) - bal
(1).synctime
> UPDATE_PER_PLBAL
THEN FOR j
= 1 TO stav.pocethracov: ipbal
(j
) = bal
(j
):
NEXT j
'fill transfer array sync_pbal = 1
IF TIMER(.001) - bal
(stav.pocethracov
+ 1).synctime
> UPDATE_PER_BAL
THEN FOR j
= 1 TO stav.pocetgulzvoleny: ibal
(j
) = bal
(j
+ stav.pocethracov
):
NEXT j
'fill transfer array sync_bal = 1
IF TIMER(.001) - hrac
(1).synctime
> UPDATE_PER_HRAC
THEN sync_hrac = 1
FOR i
= PLAYER_NET_MIN
TO PLAYER_NET_MAX
'send host data to each client sync.clientid = i
IF client
(i
).isdesynced
= 1 THEN 'send sync var if client desynced sync.synctime
= TIMER(.001) sync.itemstr = GETITEM_SYNC
PUT #client
(i
).conn
, , sync
'PRINT "Resyncing client "; i 'TEMP DEBUG line
IF sync_stav
= 1 AND client
(i
).isdesynced
= 0 THEN 'send world state sync.synctime
= TIMER(.001) sync.itemstr = GETITEM_STAV
PUT #client
(i
).conn
, , sync
stav.synctime
= TIMER(.001) PUT #client
(i
).conn
, , stav
IF sync_pbal
= 1 AND client
(i
).isdesynced
= 0 THEN 'send player balls sync.synctime
= TIMER(.001):
sync.itemstr = GETITEM_PBAL
PUT #client
(i
).conn
, , sync
bal
(1).synctime
= TIMER(.001) PUT #client
(i
).conn
, , ipbal
()
IF sync_bal
= 1 AND client
(i
).isdesynced
= 0 THEN 'send nonplayer balls sync.synctime
= TIMER(.001) sync.itemstr = GETITEM_BAL
bal
(stav.pocethracov
+ 1).synctime
= TIMER(.001) PUT #client
(i
).conn
, , sync
PUT #client
(i
).conn
, , ibal
()
IF sync_hrac
= 1 AND client
(i
).isdesynced
= 0 THEN 'IF stav.gameplay = 0 OR stav.vitaz <> 0 THEN 'send players FOR j
= 1 TO PLAYER_NET_MAX: ihrac
(j
) = hrac
(j
):
NEXT j
'fill transfer array sync.itemstr = GETITEM_HRAC
sync.synctime
= TIMER(.001) PUT #client
(i
).conn
, , sync
hrac
(1).synctime
= TIMER(.001) PUT #client
(i
).conn
, , ihrac
()
IF game.sync_stats
= 1 AND client
(i
).isdesynced
= 0 THEN 'send match statistics sync.itemstr = GETITEM_STAT
sync.synctime
= TIMER(.001) PUT #client
(i
).conn
, , sync
PUT #client
(i
).conn
, , stats
()
IF game.newmsg
= 1 AND client
(i
).isdesynced
= 0 THEN 'send new messages FOR j
= 1 TO game.msgcount
IF msg
(j
).distribute
= 1 AND msg
(j
).clientid
<> i
THEN sync.itemstr = GETITEM_MESG:
sync.synctime
= TIMER(.001):
PUT #client
(i
).conn
, , sync
msg
(j
).synctime
= TIMER(.001):
PUT #client
(i
).conn
, , msg
(j
)
game.sync_stats = 0 'clear send statistics flag
game.newmsg = 0 'clear messages distributed flags
FOR j
= 1 TO game.msgcount
msg(j).distribute = 0
'-------------------client side-------------------------------------------------------------------------------
IF game.clienth
<> 0 THEN 'client getting data from host IF game.get_isdesync
= 1 THEN 'flush acquired data if desynced 'PRINT "Resyncing... "; game.get_item 'TEMP debug line
GET #game.clienth
, , isync
'GET #game.clienth, , flush$
'PRINT "==================RESYNCED================ "; game.get_item; "-"; isync.itemstr 'TEMP debug line
game.get_item = isync.itemstr
game.get_isdesync = 0
'PRINT "Desynced!!!!!!!!!!!!! "; game.get_item 'TEMP debug line
IF game.get_item
= GETITEM_SYNC
THEN 'first get sync info on what item to get next GET #game.clienth
, , isync
IF isync.syncstr
= GETITEM_SYNC
THEN game.clientid = isync.clientid
game.get_item = isync.itemstr
game.get_time
= TIMER(.001) 'PRINT "Synced"; isync.itemstr 'TEMP debug line
game.get_isdesync = 1
IF game.get_item
= GETITEM_STAV
THEN 'get world state GET #game.clienth
, , istav
IF istav.syncstr
= GETITEM_STAV
THEN IF istav.synctime
> stav.synctime
THEN stav = istav
'PRINT "Synced"; isync.itemstr 'TEMP debug line
game.get_isdesync = 1
game.get_item = GETITEM_SYNC
IF game.get_item
= GETITEM_PBAL
THEN 'get player balls data GET #game.clienth
, , ipbal
() IF (ipbal
(1).syncstr
= GETITEM_PBAL
) THEN IF (ipbal
(1).synctime
> bal
(1).synctime
) THEN 'AND (TIMER(.001) - game.timer_pballs) < (ipbal(1).synctime - bal(1).synctime + 0.05) THEN FOR i
= 1 TO stav.pocethracov
bal(i) = ipbal(i)
game.timer_pballs
= TIMER(.001) 'PRINT "Synced"; isync.itemstr 'TEMP debug line
game.get_isdesync = 1
game.get_item = GETITEM_SYNC
IF game.get_item
= GETITEM_BAL
THEN 'get nonplayer balls data GET #game.clienth
, , ibal
() IF (ibal
(1).syncstr
= GETITEM_BAL
) THEN IF (ibal
(1).synctime
> bal
(stav.pocethracov
+ 1).synctime
) THEN FOR i
= 1 TO stav.pocetgulzvoleny
bal(stav.pocethracov + i) = ibal(i)
'PRINT "Synced"; isync.itemstr 'TEMP debug line
game.get_isdesync = 1
game.get_item = GETITEM_SYNC
IF game.get_item
= GETITEM_MESG
THEN 'get message GET #game.clienth
, , imsg
IF (imsg.syncstr
= GETITEM_MESG
) THEN AddMessage imsg.text, imsg.col, imsg.time_dur, 0
'PRINT "Synced"; isync.itemstr 'TEMP debug line
game.get_isdesync = 1
game.get_item = GETITEM_SYNC
IF game.get_item
= GETITEM_HRAC
THEN 'get players data GET #game.clienth
, , ihrac
() IF ihrac
(1).syncstr
= GETITEM_HRAC
THEN IF ihrac
(1).synctime
> hrac
(1).synctime
THEN FOR i
= 1 TO PLAYER_NET_MAX
IF i
<> game.clientid
AND game.clientid
> 0 THEN 'if another client's player hrac(i) = ihrac(i) 'get player data from host
hrac(i).klavesy = i 'set player net controlled
ELSE 'if my client player hrac(i).skore = ihrac(i).skore
hrac(i).bal = ihrac(i).bal
hrac(i).clientid = ihrac(i).clientid
'PRINT "Synced"; isync.itemstr 'TEMP debug line
game.get_isdesync = 1
game.get_item = GETITEM_SYNC
IF game.get_item
= GETITEM_STAT
THEN 'get match statistics GET #game.clienth
, , istats
() IF (istats
(PLAYER_NET_MAX
+ 1, 1) + istats
(PLAYER_NET_MAX
+ 1, 2) + istats
(PLAYER_NET_MAX
+ 1, 3)) = (ASC(GETITEM_STAT
, 1) + ASC(GETITEM_STAT
, 2) + ASC(GETITEM_STAT
, 3)) THEN stats(i, j) = istats(i, j)
game.sync_stats = 0
'PRINT "Synced"; isync.itemstr 'TEMP debug line
game.get_isdesync = 1
game.get_item = GETITEM_SYNC
IF game.clientid
> 0 THEN 'send clients data to host sync.synctime
= TIMER(.001)
'IF stav.gameplay = 1 THEN 'send client controller to host
sync.itemstr = GETITEM_KLAV
sync.synctime
= TIMER(.001) sync.isdesync = game.get_isdesync
PUT #game.clienth
, , sync
PUT #game.clienth
, , klav
(hrac
(game.clientid
).klavesy
) 'END IF
'IF stav.gameplay = 0 THEN 'send client player to host
sync.itemstr = GETITEM_HRAC
sync.synctime
= TIMER(.001) PUT #game.clienth
, , sync
PUT #game.clienth
, , hrac
(game.clientid
) 'END IF
IF game.newmsg
= 1 AND game.msgcount
> 0 THEN 'send client player to host IF msg
(game.msgcount
).distribute
= 1 THEN sync.itemstr = GETITEM_MESG
sync.synctime
= TIMER(.001) PUT #game.clienth
, , sync
PUT #game.clienth
, , msg
(game.msgcount
) msg(game.msgcount).distribute = 0
game.newmsg = 0
IF (TIMER(.001) - game.get_time
) > NET_TIMEOUT_LIMIT
THEN ResetNetGame
'----------------------------------------------------------------------------------------------------------------------------------------------------
IF client
(clidx
).conn
<> 0 THEN client(clidx).conn = 0
hrac(clidx).clientid = 0
hrac(clidx).klavesy = CPU_CONTROLID
hrac(clidx).isready = 0
bal(hrac(clidx).bal).complayer = 1
IF stav.AIallowed
= 0 AND klav
(hrac
(clidx
).klavesy
).typ
= 4 THEN bal(hrac(clidx).bal).energia = 0
CalculatePlayerState bal(hrac(clidx).bal)
AddMessage
"Player " + RTRIM$(hrac
(clidx
).meno
) + " was disconnected", MSG_COL
, MSG_DUR_STD
, 1
'----------------------------------------------------------------------------------------------------------------------------------------------------
IF game.clienth
<> 0 THEN 'try to close client connection game.clienth = 0
game.clientid = 0
stav.autostart_set = 0
AddMessage "You have been disconnected from the host", MSG_COL, MSG_DUR_STD, 0
IF game.hosth
<> 0 THEN 'try to close host service game.hosth = 0
game.clientid = 0
hrac(1).clientid = 0
AddMessage "Game hosting ended", MSG_COL, MSG_DUR_STD, 0
game.isnetgame = 0
FOR i
= 1 TO PLAYER_COUNT_MAX
hrac(i).clientid = 0
IF (klav
(hrac
(i
).klavesy
).typ
= 5) OR (i
> PLAYER_NET_MAX
AND klav
(hrac
(i
).klavesy
).typ
<> 4) THEN hrac(i).klavesy = CPU_CONTROLID
bal(hrac(i).bal).complayer = 1
'----------------------------------------------------------------------------------------------------------------------------------------------------
IF game.clienth
<> 0 THEN ResetNetGame
game.isnetgame = 1
game.clientid = 1
hrac(1).clientid = 1
AddMessage "Game hosting started", MSG_COL, MSG_DUR_STD, 0
game.isnetgame = 0
ResetNetGame
'----------------------------------------------------------------------------------------------------------------------------------------------------
IF game.hosth
<> 0 THEN ResetNetGame
AddMessage
"Connecting to" + RTRIM$(STR$(game.host_port
)) + ":" + RTRIM$(game.host_ip
) + "...", MSG_COL
, MSG_DUR_STD
, 0 DisplayMessages
game.isnetgame = 1
game.get_item = GETITEM_SYNC
game.get_isdesync = 0
game.get_time
= TIMER(.001) game.timer_pballs
= TIMER(.001) AddMessage "Connection opened, joining the game...", MSG_COL, MSG_DUR_STD, 0
game.isnetgame = 0
ResetNetGame
'----------------------------------------------------------------------------------------------------------------------------------------------------
clrstr$ = ""
tmpstr$ = ""
FOR i
= 1 TO inputwidth: clrstr$
= clrstr$
+ " ":
NEXT i
IF res$
= "" THEN tmpstr$
= hint
ELSE tmpstr$
= res$
IF k
= 13 THEN InputText$
= res$
'----------------------------------------------------------------------------------------------------------------------------------------------------
IF fixedwidth
> 0 THEN slen
= fixedwidth
px
= INT((game.maxx
- slen
) / 2) + deltax
py = amenu.ypos + (id - 1) * amenu.item_height
IF id
= amenu.item_active
THEN _PRINTSTRING (amenu.cursor_xpos
+ amenu.cursor_width
+ 10, py
), ">" amenu.menucode = menucode
amenu.playercode = playercode
'----------------------------------------------------------------------------------------------------------------------------------------------------
SUB PrintMenuCursor
(amenu
AS tmenu
) 'print menu cursor py = amenu.ypos + (amenu.item_active - 1) * amenu.item_height
LINE (amenu.cursor_xpos
- amenu.cursor_out
, game.maxy
- (py
- amenu.cursor_out
))-(amenu.cursor_xpos
+ amenu.cursor_out
+ amenu.cursor_width
, game.maxy
- (py
+ FONT_H
) - amenu.cursor_out
), amenu.cursor_col
, B
'----------------------------------------------------------------------------------------------------------------------------------------------------
SUB PauseGame
'pause gameplay winstr$ = "-> Game paused <-"
_PRINTSTRING ((game.maxx
- LEN(winstr$
) * 10) / 2, (game.maxy
- 50) / 2), winstr$
'----------------------------------------------------------------------------------------------------------------------------------------------------
SUB DrawBall
(baln
AS gula
) 'draw ball koef = (10 + 90 * game.printdebug) * FPS / 100
bcol = baln.col
IF baln.freezedtime
> 0 THEN bcol
= 27 CIRCLE (baln.x
, baln.y
), baln.r
- 1, baln.col
CIRCLE (baln.x
, baln.y
), baln.r
+ 1, baln.col
CIRCLE (baln.x
, baln.y
), i
* (baln.r
/ 2 - 2) / BSEGM
, bcol
, 0, baln.energia
/ stav.energy_player_start
* _PI * 2 LINE (baln.x
, baln.y
)-(baln.x
+ baln.v.x
* koef
, baln.y
+ baln.v.y
* koef
), baln.col
'draw actual velocity IF game.printdebug
= 1 THEN LINE (baln.x
, baln.y
)-(baln.x
+ baln.vi.x
* koef
, baln.y
+ baln.vi.y
* koef
), bal
(baln.protivnik
).col
'draw intended velocity CIRCLE (baln.x
, baln.y
), baln.r
* 2 / 3, 15 IF baln.i
> stav.pocethracov
THEN reflectfrom
= ATN((1.25 * stav.maxy
- baln.y
) / (1.25 * stav.maxx
- baln.x
)) CIRCLE (baln.x
, baln.y
), baln.r
- 5, 28, reflectfrom
, reflectfrom
+ _PI / 8 CIRCLE (baln.x
, baln.y
), baln.r
- 5, 28, reflectfrom
+ _PI / 8 + _PI / 32, reflectfrom
+ _PI / 4 CIRCLE (baln.x
, baln.y
), baln.r
- 10, 28, reflectfrom
, reflectfrom
+ _PI / 8 CIRCLE (baln.x
, baln.y
), baln.r
- 10, 28, reflectfrom
+ _PI / 8 + _PI / 32, reflectfrom
+ _PI / 4
CIRCLE (baln.x
, baln.y
), baln.r
, baln.col
'----------------------------------------------------------------------------------------------------------------------------------------------------
SUB DrawScore
'Draw player score WINDOW (0, 0)-(game.maxx
, game.maxy
) FOR i
= 1 TO stav.pocethracov
scxl = SCORE_DELTA_X * -(game.maxx >= 4 * SCORE_DELTA_X) + game.maxx / 4 * -(game.maxx < 4 * SCORE_DELTA_X)
dx = (game.maxx - 4 * scxl) / 2
scx
= dx
+ scxl
* ((i
- 4 * INT((i
- 1) / 4)) - 1) scty
= SCORE_DELTA_Y
+ 15 * INT((i
- 1) / 4) scly
= game.maxy
- SCORE_DELTA_Y
- 15 * INT((i
- 1) / 4) COLOR bal
(hrac
(i
).bal
).col
LINE (scx
+ SCORE_NAME_LEN
, scly
)-(scx
+ SCORE_NAME_LEN
+ bal
(hrac
(i
).bal
).energia
, scly
+ 7), bal
(hrac
(i
).bal
).col
, BF
IF bal
(hrac
(i
).bal
).energia
<= 0 THEN WINDOW (0, 0)-(stav.maxx
, stav.maxy
)
'----------------------------------------------------------------------------------------------------------------------------------------------------
SUB CalculatePlayerState
(baln
AS gula
) 'calculate players states '-----------------------energy decreasing-------------------------------------
baln.freezedtime = baln.freezedtime - 1
baln.energia = baln.energia - (stav.energydec * -(stav.baljeto = baln.i)) * game.fpscoef
baln.riadena = 0
pocetriadenych = 0
FOR i
= 1 TO stav.pocethracov
IF bal
(hrac
(i
).bal
).riadena
= 1 THEN pocetriadenych = pocetriadenych + 1
priebeznyvitaz = i
stav.baljeto = stav.balbudeto
stav.balbudeto = nearestPlayer(bal(stav.baljeto), 0, 0)
FOR i
= 1 TO stav.pocetgulx
IF bal
(i
).i
<> stav.baljeto
AND bal
(i
).riadena
= 1 THEN bal
(i
).protivnik
= stav.baljeto
stav.vitaz = priebeznyvitaz
hrac(stav.vitaz).skore = hrac(stav.vitaz).skore + 1
IF hrac
(stav.vitaz
).skore
>= stav.winscore
THEN game.autostart_time
= TIMER + DELAY_MATCHEND
ELSE game.autostart_time
= TIMER + DELAY_ROUNDSTART
DrawScore
'-----------------------dodging time-----------------------------------------
IF baln.klucka_time
= 0 AND baln.klucka_trvanie
= 0 AND baln.klucka_pocet
= 0 THEN baln.klucka_time
= INT(RND * strat
(baln.strat
).klucka_avgtm
+ strat
(baln.strat
).klucka_avgtm
/ 2) / game.fpscoef
baln.klucka_pocet = strat(baln.strat).klucka_pocet
baln.klucka_time = baln.klucka_time - 1
IF baln.klucka_time
= 0 AND baln.klucka_trvanie
> 0 THEN baln.klucka_trvanie = baln.klucka_trvanie - 1
IF baln.klucka_time
= 0 AND baln.klucka_trvanie
= 0 AND baln.klucka_pocet
> 0 THEN baln.klucka_pocet = baln.klucka_pocet - 1
baln.klucka_trvanie
= INT(RND * strat
(baln.strat
).klucka_trvanie
+ strat
(baln.strat
).klucka_trvanie
/ 2) / game.fpscoef
baln.klucka_uhol
= RND * strat
(baln.strat
).klucka_uhol
* (2 * strat
(baln.strat
).klucka_uholodch
) + strat
(baln.strat
).klucka_uhol
* (1 - strat
(baln.strat
).klucka_uholodch
) * (3 - INT(RND * 2 + 1) * 2) '-----------------------choose nearest enemy if tagged-----------------------
novyprotivnik = nearestPlayer(baln, 0, -(baln.energia > (stav.energy_player_start * strat(baln.strat).adrenalin_energy)))
IF novyprotivnik
<> 0 THEN baln.protivnik
= novyprotivnik
stav.balbudeto = nearestPlayer(baln, 0, 0)
'-----------------------boosting time----------------------------------------
IF baln.boost_time
> 0 AND baln.boost_trvanie
= 0 THEN baln.boost_time
= baln.boost_time
- 1 IF baln.boost_trvanie
> 0 THEN baln.boost_trvanie
= baln.boost_trvanie
- 1
'-----------------------reaction drop time-----------------------------------
IF baln.reactdrop_time
> 0 THEN baln.reactdrop_time
= baln.reactdrop_time
- 1 IF baln.reactdrop_time
<= 0 AND baln.reactdrop_dur
> 0 THEN baln.reactdrop_dur
= baln.reactdrop_dur
- 1 IF baln.reactdrop_time
<= 0 AND baln.reactdrop_dur
<= 0 THEN IF baln.energia
< (stav.energy_player_start
* strat
(baln.strat
).adrenalin_energy
) THEN reactkoef
= (1 - strat
(baln.strat
).adrenalin_rate
) ELSE reactkoef
= 1 baln.reactdrop_time
= INT((RND * strat
(baln.strat
).reactdrop_per
* reactkoef
+ strat
(baln.strat
).reactdrop_per
* reactkoef
/ 2) / game.fpscoef
) baln.reactdrop_dur
= INT((RND * strat
(baln.strat
).reactdrop_dur
* reactkoef
+ strat
(baln.strat
).reactdrop_dur
* reactkoef
/ 2) / game.fpscoef
) baln.smer_odchyl
= (RND * strat
(baln.strat
).chybasmeru
- strat
(baln.strat
).chybasmeru
/ 2) * pi
'apply random radian deviance from intended direction
'----------------------------------------------------------------------------------------------------------------------------------------------------
CONST NEAREST_WEIGHTCOEF
= 10.0 'coeficient for energy inclusion into weight vzdakt = 0
nearestPlayer = 0
vzdakt_winner = 0
nearest_winner = 0
FOR i
= 1 TO stav.pocetgulx
IF bal
(i
).i
<> baln.i
AND bal
(i
).riadena
= 1 AND (mateonly
= 1 IMP i
<> stav.baljeto
) THEN weight = weighted * (stav.energy_player_start - bal(i).energia) * NEAREST_WEIGHTCOEF
vzd
= SQR((baln.x
- bal
(i
).x
) ^ 2 + (baln.y
- bal
(i
).y
) ^ 2) + weight
IF nearestPlayer
= 0 OR vzd
< vzdakt
THEN nearestPlayer = i
vzdakt = vzd
IF hrac
(bal
(i
).hrac
).skore
= stav.winscore
- 1 AND (vzd
< vzdakt_winner
OR nearest_winner
= 0) THEN nearest_winner = i
vzdakt_winner = vzd
IF weighted
= 1 AND nearest_winner
> 0 THEN nearestPlayer
= nearest_winner
'----------------------------------------------------------------------------------------------------------------------------------------------------
SUB GenerateAIControl
(baln
AS gula
) 'Decide computer player's control keys hits DIM d
AS vektor
, vi
AS vektor
, ei
AS vektor
, ve
AS vektor
, di
AS vektor
, dm
AS vektor
vi = baln.vi 'player's intended speed vector copy
vid
= SQR(vi.x
^ 2 + vi.y
^ 2) vi.x = vi.x / vid * stav.vmax
vi.y = vi.y / vid * stav.vmax
vd
= SQR(baln.v.x
^ 2 + baln.v.y
^ 2) ve = bal(baln.protivnik).v 'enemy speed vector copy
ved
= SQR(ve.x
^ 2 + ve.y
^ 2)
d.x = bal(baln.protivnik).x - baln.x 'player to enemy postition vector
d.y = bal(baln.protivnik).y - baln.y
dd
= SQR(d.x
^ 2 + d.y
^ 2) coser = (d.x * baln.v.x + d.y * baln.v.y) / (dd * vd)
siner = (d.x * baln.v.y - d.y * baln.v.x) / (dd * vd)
cosevr = (ve.x * baln.v.x + ve.y * baln.v.y) / (ved * vd)
sinevr = (ve.x * baln.v.y - ve.y * baln.v.x) / (ved * vd)
'!EXPERIMENTAL CODE! - try more exact enemy future position vector, but does not work so well as used approximation
'di.x = d.x + ve.x * d.x / ((((d.x / dd) + (ve.x / ved)) * stav.vmax) - ve.x) 'new intended direction to enemy
'di.y = d.y + ve.y * d.y / ((((d.y / dd) + (ve.y / ved)) * stav.vmax) - ve.y) 'new intended direction to enemy
'!EXPERIMENTAL CODE! end
di.x
= d.x
+ ve.x
* dd
/ vd
* ABS(siner
) 'player to enemy approximate future position vector, future enemy position more relevant when enemy closer di.y
= d.y
+ ve.y
* dd
/ vd
* ABS(siner
) did
= SQR(di.x
^ 2 + di.y
^ 2) coseri = (di.x * baln.v.x + di.y * baln.v.y) / (did * vd)
sineri = (di.x * baln.v.y - di.y * baln.v.x) / (did * vd)
rot_enemy = 0 'rotation away from enemy in rad
rot_border = 0 'rotation away from border in rad
rot_mate = 0 'rotation towards nearest mate in rad
rot_odchyl = 0 'baln.smer_odchyl * -(baln.reactdrop_dur = 1) 'apply direction error if react time
smerdookraju = 0 'is players direction to border
IF NOT (stav.baljeto
= baln.i
) THEN 'decide flee action enemy_dist_factor = 1 * -(dd <= strat(baln.strat).detekcia_vzdfull) + (1 - (dd - strat(baln.strat).detekcia_vzdfull) / _
(strat
(baln.strat
).detekcia_vzdmin
- strat
(baln.strat
).detekcia_vzdfull
)) * -(dd
> strat
(baln.strat
).detekcia_vzdfull
AND dd
<= strat
(baln.strat
).detekcia_vzdmin
)' factor=1 if enemy distance within treshold, then decreasing
IF enemy_dist_factor
> 0 THEN 'if enemy in detection distance, rotate away rot_enemy
= -(coseri
> 0) * -(ABS(sineri
) <= strat
(baln.strat
).detekcia_sin
) * (-(sineri
> 0) + (sineri
< 0)) * strat
(baln.strat
).detekcia_rot
* enemy_dist_factor
* game.fpscoef
'!EXPERIMENTAL CODE! - try better rotation from enemy
'strat(baln.strat).detekcia_rot = 10 * pi / FPS 'TEMPORARY MODIFICATION
'cosevi = (di.x * vi.x + di.y * vi.y) / (did * vid)
'sinevi = (di.x * vi.y - di.y * vi.x) / (did * vid)
'cosvvi = (v.x * vi.x + v.y * vi.y) / (vd * vid)
'sinvvi = (v.x * vi.y - v.y * vi.x) / (vd * vid)
'IF (coseri > 0) AND (ABS(sineri) <= strat(baln.strat).detekcia_sin) THEN
' rot_dir = -(sineri > 0) + (sineri < 0)
' IF NOT ((cosevi > 0 AND (ABS(sinevi) <= strat(baln.strat).detekcia_sin)) AND NOT (rot_dir = (-(sinevi > 0) + (sinevi < 0)))) THEN
' rot_enemy = rot_dir * strat(baln.strat).detekcia_rot * enemy_dist_factor * game.fpscoef
' END IF
'END IF
'!EXPERIMENTAL CODE! end
okrajrot = strat(baln.strat).okraj_rot 'border unit rotation in rad
IF baln.x
< strat
(baln.strat
).okraj
AND vi.x
< 0 THEN rot_border = (okrajrot * (vi.y >= 0) + okrajrot * -(vi.y < 0)) '* (1 - enemy_dist_factor)
smerdookraju = 1
IF baln.x
> stav.maxx
- strat
(baln.strat
).okraj
AND vi.x
> 0 THEN rot_border = (okrajrot * -(vi.y >= 0) + okrajrot * (vi.y < 0)) '* (1 - enemy_dist_factor)
smerdookraju = 1
IF baln.y
< strat
(baln.strat
).okraj
AND vi.y
< 0 THEN rot_border = (okrajrot * (vi.x >= 0) + okrajrot * (vi.x < 0)) '* (1 - enemy_dist_factor)
smerdookraju = 1
IF baln.y
> stav.maxy
- strat
(baln.strat
).okraj
AND vi.y
> 0 THEN rot_border = (okrajrot * (vi.x >= 0) + okrajrot * -(vi.x < 0)) '* (1 - enemy_dist_factor)
smerdookraju = 1
rot_klucka = baln.klucka_uhol * -(baln.klucka_time = 0) * -(baln.klucka_trvanie = 1) * -(stav.baljeto <> baln.i) * _
(dd
> strat
(baln.strat
).mate_distmin
OR (coseri
< 0 AND sineri
>= 0 AND baln.klucka_uhol
> 0 AND baln.klucka_uhol
< pi
) OR (coseri
< 0 AND sineri
<= 0 AND baln.klucka_uhol
< 0 AND baln.klucka_uhol
> -pi
)) 'apply dodge if dodging time - TEMPORARY DISABLED!!!
IF baln.i
= bal
(stav.baljeto
).protivnik
THEN 'if ball being chased nearmate = nearestPlayer(baln, 1, -(baln.energia > (stav.energy_player_start * strat(baln.strat).adrenalin_energy)))
dm.x = bal(nearmate).x - baln.x
dm.y = bal(nearmate).y - baln.y
dmd
= SQR(dm.x
^ 2 + dm.y
^ 2) cosnm = (dm.x * baln.v.x + dm.y * baln.v.y) / (dmd * vd)
sinnm = (dm.x * baln.v.y - dm.y * baln.v.x) / (dmd * vd)
IF (rot_border
= 0) AND (dmd
> strat
(baln.strat
).mate_distmin
) AND (((coseri
< strat
(baln.strat
).mate_cosenmax
) AND (dd
< strat
(baln.strat
).mate_en_distmin
)) OR ((coseri
< 0) AND (dd
> strat
(baln.strat
).mate_en_distmin
))) THEN rot_mate = ((sinnm > 0) * strat(baln.strat).mate_rot * game.fpscoef - (sinnm <= 0) * strat(baln.strat).mate_rot * game.fpscoef) 'rotate towards mate
RotateVector vi, rot_border + rot_klucka + rot_odchyl + rot_enemy + rot_mate 'aplly all calculated rotations to intended velocity
IF stav.baljeto
= baln.i
THEN 'chasing direction intended IF baln.reactdrop_time
> 0 THEN 'if time is up for reaction baln.boostintended
= -(-(coser
> 0) AND -(cosevr
> 0) AND -(ABS(sinevr
) < strat
(baln.strat
).boost_chasesin
) AND baln.boost_time
= 0 AND smerdookraju
= 0) baln.vi.x = stav.vmax * di.x / did
baln.vi.y = stav.vmax * di.y / did
ELSE 'flee direction intended baln.boostintended
= -(-(coser
< 0) AND baln.boost_time
= 0 AND dd
< (RND * strat
(baln.strat
).boost_dist
+ 2 * PLAY_BALL_R
) AND smerdookraju
= 0) baln.vi.x = vi.x
baln.vi.y = vi.y
'----------------------------------------------------------------------------------------------------------------------------------------------------
SUB ReadGamepad
(klavn
AS tklavesy
) 'read state of gamepad klavn.gvektor.x
= _AXIS(klavn.xaxis
) klavn.gvektor.y
= -_AXIS(klavn.yaxis
) klavn.isshoota
= _BUTTON(klavn.shoota
) klavn.isshootb
= _BUTTON(klavn.shootb
) klavn.isup
= (_AXIS(klavn.dyaxis
) = -1) klavn.isdown
= (_AXIS(klavn.dyaxis
) = 1) klavn.isleft
= (_AXIS(klavn.dxaxis
) = -1) klavn.isright
= (_AXIS(klavn.dxaxis
) = 1) IF klavn.gvektor.x
> 0.5 THEN klavn.isright
= -1 IF klavn.gvektor.x
< -0.5 THEN klavn.isleft
= -1 IF klavn.gvektor.y
> 0.5 THEN klavn.isup
= -1 IF klavn.gvektor.y
< -0.5 THEN klavn.isdown
= -1
IF klavn.buttonstate
<> (klavn.isshoota
+ klavn.isshootb
* 2 + klavn.isup
* 4 + klavn.isdown
* 8 + klavn.isright
* 16 + klavn.isleft
* 32) THEN klavn.buttonstatechanged = -1
klavn.buttonstatetimer = 50
klavn.buttonstatechanged = 0
klavn.buttonstate = (klavn.isshoota + klavn.isshootb * 2 + klavn.isup * 4 + klavn.isdown * 8 + klavn.isright * 16 + klavn.isleft * 32)
IF klavn.buttonstatetimer
> 0 THEN klavn.buttonstatetimer
= klavn.buttonstatetimer
- 1 IF klavn.buttonstatetimer
= 0 THEN klavn.buttonstatechanged
= -1
'----------------------------------------------------------------------------------------------------------------------------------------------------
SUB ResolvePlayerControl
(baln
AS gula
, klavn
AS tklavesy
) 'perform players control keys actions DIM vn
AS vektor
, gvector
AS vektor
IF baln.complayer
= 0 THEN 'read human player controls IF klavn.typ
= 1 THEN 'read keyboard control baln.vi.x = baln.v.x
baln.vi.y = baln.v.y
IF klavn.typ
= 3 THEN 'read gamepad control baln.vi.x = 0
baln.vi.y = 0
ReadGamepad klavn
baln.vi.x = klavn.gvektor.x * stav.vmax
baln.vi.y = klavn.gvektor.y * stav.vmax
IF ABS(klavn.gvektor.x
) > GAMESTICK_DEADZONE
OR ABS(klavn.gvektor.y
) > GAMESTICK_DEADZONE
THEN klavn.isright = (baln.v.x < baln.vi.x) 'set control keys status for desired direction
klavn.isleft = (baln.v.x > baln.vi.x)
klavn.isup = (baln.v.y < baln.vi.y)
klavn.isdown = (baln.v.y > baln.vi.y)
IF klavn.isshootb
AND game.isnetgame
= 0 THEN stav.koniec_kola
= 2
IF game.clienth
<> 0 THEN ' reset network controller state on client klavn.isright = (baln.v.x < baln.vi.x) 'set control keys status for desired direction
klavn.isleft = (baln.v.x > baln.vi.x)
klavn.isup = (baln.v.y < baln.vi.y)
klavn.isdown = (baln.v.y > baln.vi.y)
'klavn.isright = 0
'klavn.isleft = 0
'klavn.isup = 0
'klavn.isdown = 0
klavn.isshoota = 0
baln.vi.x = baln.v.x
baln.vi.y = baln.v.y
ELSE 'get controls of computer player IF baln.riadena
= 1 THEN GenerateAIControl baln
klavn.isright = (baln.v.x < baln.vi.x) 'set control keys status for desired direction
klavn.isleft = (baln.v.x > baln.vi.x)
klavn.isup = (baln.v.y < baln.vi.y)
klavn.isdown = (baln.v.y > baln.vi.y)
klavn.isshoota = -baln.boostintended
IF baln.freezedtime
<= 0 AND baln.riadena
= 1 THEN 'apply acquired controls to player movement vn.x = baln.v.x
vn.y = baln.v.y
game.fpscoef = stav.fps / game.fpsactual
IF klavn.isright
THEN vn.x
= vn.x
+ baln.a.x
* game.fpscoef
'accelerate player according to control keys states IF klavn.isleft
THEN vn.x
= vn.x
- baln.a.x
* game.fpscoef
IF klavn.isdown
THEN vn.y
= vn.y
- baln.a.y
* game.fpscoef
IF klavn.isup
THEN vn.y
= vn.y
+ baln.a.x
* game.fpscoef
IF klavn.isshoota
AND baln.boost_time
= 0 AND stav.boostallowed
= 1 THEN 'set boost state baln.boost_trvanie = BOOST_TRVANIE / game.fpscoef
baln.boost_time = BOOST_TIME / game.fpscoef
vnd
= SQR(vn.x
^ 2 + vn.y
^ 2) 'limit actual velocity to max. velocity vn.x = vn.x * stav.vmax / vnd
vn.y = vn.y * stav.vmax / vnd
IF baln.boost_trvanie
> 0 THEN 'add some extra speed if boosted vn.x = vn.x + stav.vmax * BOOST_V_KOEF * (baln.boost_trvanie / BOOST_TRVANIE) * game.fpscoef * vn.x / vnd
vn.y = vn.y + stav.vmax * BOOST_V_KOEF * (baln.boost_trvanie / BOOST_TRVANIE) * game.fpscoef * vn.y / vnd
baln.v.x = vn.x 'apply controler modified velocity
baln.v.y = vn.y
'----------------------------------------------------------------------------------------------------------------------------------------------------
SUB PerformMovement
(baln
AS gula
) 'Calculate ball movement baln.x = baln.x + baln.v.x * game.fpscoef
baln.y = baln.y + baln.v.y * game.fpscoef
baln.v.x = baln.v.x * stav.odpor ^ game.fpscoef
baln.v.y = baln.v.y * stav.odpor ^ game.fpscoef
IF (baln.x
+ baln.r
> stav.maxx
) THEN baln.v.x = -baln.v.x
baln.x = stav.maxx - baln.r
IF (baln.x
- baln.r
< stav.minx
) THEN baln.v.x = -baln.v.x
baln.x = stav.minx + baln.r
IF (baln.y
+ baln.r
> stav.maxy
) THEN baln.v.y = -baln.v.y
baln.y = stav.maxy - baln.r
IF (baln.y
- baln.r
< stav.miny
) THEN baln.v.y = -baln.v.y
baln.y = stav.miny + baln.r
'----------------------------------------------------------------------------------------------------------------------------------------------------
SUB BounceTest
(bala
AS gula
, balb
AS gula
) 'Balls bounce test IF (bala.x
- balb.x
) * (bala.x
- balb.x
) + (bala.y
- balb.y
) * (bala.y
- balb.y
) <= (bala.r
+ balb.r
+ 0) * (bala.r
+ balb.r
+ 0) THEN PerformBounce bala, balb
IF bala.riadena
AND balb.riadena
AND bala.freezedtime
<= 0 AND balb.freezedtime
<= 0 AND (stav.baljeto
= bala.i
OR stav.baljeto
= balb.i
) THEN 'balb.col = bal(bala.protivnik).col newjeto = bala.i * -(stav.baljeto <> bala.i) + balb.i * -(stav.baljeto <> balb.i)
IF stav.baljeto
<= PLAYER_NET_MAX
AND newjeto
<= PLAYER_NET_MAX
AND (game.isnetgame
= 0 OR game.hosth
<> 0) THEN stats(stav.baljeto, newjeto) = stats(stav.baljeto, newjeto) + 1
game.sync_stats = 1
stav.baljeto = newjeto
bala.freezedtime = -(stav.baljeto = bala.i) * FREEZE_TIME / game.fpscoef
balb.freezedtime = -(stav.baljeto = balb.i) * FREEZE_TIME / game.fpscoef
bala.protivnik = balb.i
balb.protivnik = bala.i
FOR i
= 1 TO stav.pocetgulx
IF bal
(i
).i
<> stav.baljeto
AND bal
(i
).riadena
= 1 THEN bal
(i
).protivnik
= bal
(stav.baljeto
).i
'----------------------------------------------------------------------------------------------------------------------------------------------------
SUB PerformBounce
(bala
AS gula
, balb
AS gula
) 'Calculate balls bounce
ma = bala.m
mb = balb.m
ma = 1
mb = 1
dx = balb.x - bala.x
dy = balb.y - bala.y
p = bala.r + balb.r - d 'Move overlapping balls away from each other
bala.x = bala.x - dx * p / d / 2 * 2
bala.y = bala.y - dy * p / d / 2 * 2
balb.x = balb.x + dx * p / d / 2 * 2
balb.y = balb.y + dy * p / d / 2 * 2
dx = balb.x - bala.x
dy = balb.y - bala.y
cosa = dy / d
cosb = -cosa
l = (dx * bala.v.x * ma + dy * bala.v.y * ma) / d
l2 = l * cosa
k = (dy * bala.v.x * ma - dx * bala.v.y * ma) / d
k1 = k * cosa
l1 = bala.v.x * ma - k1
k2 = bala.v.y * ma - l2
n = (-dx * balb.v.x * mb - dy * balb.v.y * mb) / d
n2 = n * cosb
m = (-dy * balb.v.x * mb + dx * balb.v.y * mb) / d
m1 = m * cosb
n1 = balb.v.x * mb - m1
m2 = balb.v.y * mb - n2
bala.v.x = (k1 + n1) / ma
bala.v.y = (k2 + n2) / ma
balb.v.x = (m1 + l1) / mb
balb.v.y = (m2 + l2) / mb
'----------------------------------------------------------------------------------------------------------------------------------------------------
MATHROUND
= FIX(n
+ 0.5 * SGN(n
))
'----------------------------------------------------------------------------------------------------------------------------------------------------
vt.x = vn.x * cosb - vn.y * sinb
vt.y = vn.y * cosb + vn.x * sinb
vn = vt
'----------------------------------------------------------------------------------------------------------------------------------------------------
SUB CalculateFps
'calculate actual fps coeficient for correct timig IF game.tend
= game.tstart
THEN game.fpsactual = stav.fps
game.fpsactual = ((1 / (game.tend - game.tstart)) * 1 + game.fpsactual * 99) / 100
game.tstart = game.tend
game.fpscoef = stav.fps / game.fpsactual
'----------------------------------------------------------------------------------------------------------------------------------------------------
IF game.msgcount
> 0 THEN 'refresh messages validity FOR i
= 1 TO game.msgcount
IF ((TIMER(.001) - msg
(i
).time_start
) > msg
(i
).time_dur
) AND msg
(i
).time_dur
> 0 THEN DeleteMessage
(i
) IF game.msgcount
> 0 THEN 'print messages FOR i
= 1 TO game.msgcount
'----------------------------------------------------------------------------------------------------------------------------------------------------
TextCommand mtext
IF game.msgcount
>= MSG_COUNT_MAX
THEN DeleteMessage
(1) 'delete last message if full game.msgcount = game.msgcount + 1
msg(game.msgcount).clientid = game.clientid
msg(game.msgcount).text = mtext
msg(game.msgcount).col = mcol
msg(game.msgcount).time_dur = mdur
msg
(game.msgcount
).time_start
= TIMER(.001) msg(game.msgcount).syncstr = "SNM"
msg(game.msgcount).synctime = 0
msg(game.msgcount).distribute = mdist
IF mdist
= 1 THEN game.newmsg
= 1
'----------------------------------------------------------------------------------------------------------------------------------------------------
FOR i
= mid
TO game.msgcount
- 1 msg(i) = msg(i + 1)
game.msgcount = game.msgcount - 1
'----------------------------------------------------------------------------------------------------------------------------------------------------
CASE "/q" 'end network game IF game.hosth
<> 0 AND stav.gameplay
= 1 THEN stav.koniec_kola = 2
AddMessage "The match has been ended by the host", MSG_COL, MSG_DUR_STD, 1
IF game.clienth
<> 0 AND stav.gameplay
= 1 THEN stav.koniec_kola = 2
ResetNetGame
CASE "/d" 'disconnet client clidx IF game.hosth
<> 0 AND clidx
> 1 AND clidx
<= PLAYER_NET_MAX
THEN IF client
(clidx
).conn
<> 0 THEN CloseClientConn clidx
AddMessage
"Player " + RTRIM$(hrac
(clidx
).meno
) + " was disconnected by host", MSG_COL
, MSG_DUR_STD
, 1
'----------------------------------------------------------------------------------------------------------------------------------------------------
SUB DebugScreen
(K
AS INTEGER) 'print debyg information on screen in runtime LOCATE INT((stav.pocethracov
- 0.5) / 4) + 2, 1 PRINT "FPS: "; game.fpsactual
IF K
= 101 THEN stav.energydec
= -(stav.energydec
= 0) * ENERGY_DEC
bal(hrac(2).bal).strat = bal(hrac(2).bal).strat + 1
bal(hrac(2).bal).strat = 1
PRINT "hrac(n)..isleft "; klav
(hrac
(1).klavesy
).isleft; klav
(hrac
(2).klavesy
).isleft; klav
(hrac
(3).klavesy
).isleft; klav
(hrac
(4).klavesy
).isleft
PRINT "hrac(n)..isright "; klav
(hrac
(1).klavesy
).isright; klav
(hrac
(2).klavesy
).isright; klav
(hrac
(3).klavesy
).isright; klav
(hrac
(4).klavesy
).isright
PRINT "hrac(n)..isdown "; klav
(hrac
(1).klavesy
).isdown; klav
(hrac
(2).klavesy
).isdown; klav
(hrac
(3).klavesy
).isdown; klav
(hrac
(4).klavesy
).isdown
PRINT "hrac(n)..isup "; klav
(hrac
(1).klavesy
).isup; klav
(hrac
(2).klavesy
).isup; klav
(hrac
(3).klavesy
).isup; klav
(hrac
(4).klavesy
).isup
PRINT "bal(2).vi "; bal
(hrac
(2).bal
).vi.x; bal
(hrac
(2).bal
).vi.y
PRINT "bal(3).vi "; bal
(hrac
(3).bal
).vi.x; bal
(hrac
(3).bal
).vi.y
PRINT "bal(4).vi "; bal
(hrac
(4).bal
).vi.x; bal
(hrac
(4).bal
).vi.y
PRINT "bal(2).strat "; bal
(2).strat
PRINT "bal(2).klucka_time "; bal
(hrac
(2).bal
).klucka_time
PRINT "bal(2).klucka_pocet "; bal
(hrac
(2).bal
).klucka_pocet
PRINT "bal(2).klucka_trvanie "; bal
(hrac
(2).bal
).klucka_trvanie
PRINT "bal(2).klucka_uhol "; bal
(hrac
(2).bal
).klucka_uhol
PRINT "bal(n).protivnik "; bal
(1).protivnik; bal
(2).protivnik; bal
(3).protivnik
PRINT "bal(n).complayer "; bal
(1).protivnik; bal
(2).protivnik; bal
(3).protivnik
PRINT "stav.baljeto "; stav.baljeto
PRINT "stav.koniec_kola "; stav.koniec_kola
PRINT "nearestPlayer(1) "; nearestPlayer
(bal
(1), 0, 1) PRINT "bal(n).reactdrop_time _dur "; bal
(2).reactdrop_time; bal
(2).reactdrop_dur
PRINT "bal(1).v "; bal
(1).v.x; bal
(1).v.y
PRINT "bal(1).a "; bal
(1).a.x; bal
(1).a.y
PRINT "bal(2).boostintended "; bal
(2).boostintended
PRINT "bal(2).boost_time "; bal
(1).boost_time
PRINT "bal(2).boost_trvanie "; bal
(1).boost_trvanie
PRINT "bal(n).hrac "; bal
(1).hrac; bal
(2).hrac; bal
(3).hrac; bal
(4).hrac
PRINT "bal(1).syncstr "; bal
(1).syncstr
PRINT "game.autostart_time "; game.autostart_time
PRINT "stav.autostart_set "; stav.autostart_set
PRINT "client(n).conn"; client
(1).conn; client
(2).conn; client
(3).conn; client
(4).conn
PRINT "hrac(n).klavesy"; hrac
(1).klavesy; hrac
(2).klavesy; hrac
(3).klavesy; hrac
(4).klavesy; hrac
(10).klavesy
PRINT "klav(hrac(n)klavesy).typ"; klav
(hrac
(1).klavesy
).typ; klav
(hrac
(2).klavesy
).typ; klav
(hrac
(3).klavesy
).typ; klav
(hrac
(4).klavesy
).typ; klav
(hrac
(10).klavesy
).typ
PRINT "game.sync_stats "; game.sync_stats
'----------------------------------------------------------------------------------------------------------------------------------------------------