@@ -6,7 +6,7 @@ local zombie = require "zombie"
66local player = require " player"
77
88function love .load ()
9- love .window .setFullscreen ( true )
9+ love .window .setMode ( 1000 , 600 )
1010 GameClient = game .newClient (22122 )
1111 love .window .setTitle ( " Client" )
1212
@@ -113,8 +113,14 @@ function love.draw()
113113 table.sort (sortedByScore , function (a , b ) return a [2 ].score > b [2 ].score end )
114114 for _ , v in pairs (sortedByScore ) do
115115 local playerObj = v [2 ]
116- if playerObj .id == GameClient .player .id then love .graphics .setColor (1 , 0 , 0 , 1 ) end
117- love .graphics .printf (playerObj .name .. " :: Zombies killed: " .. playerObj .score .. " , Accuracy: " .. string.format (" %.2f %%" , playerObj .accuracy ), Fonts .s ,20 , love .graphics .getHeight ()- height , love .graphics .getWidth (), " left" )
116+ local playerName = playerObj .name
117+ if playerObj .id == GameClient .player .id then
118+ love .graphics .setColor (0.2 , 0.2 , 0.8 , 1 )
119+ playerName = playerName .. " *"
120+ else
121+ playerName = playerName .. " "
122+ end
123+ love .graphics .printf (playerName .. " :: Zombies killed: " .. playerObj .score .. " , Accuracy: " .. string.format (" %.2f %%" , playerObj .accuracy ), Fonts .s ,20 , love .graphics .getHeight ()- height , love .graphics .getWidth (), " left" )
118124 love .graphics .setColor (0 , 0 , 0 , 1 )
119125 height = height - 30
120126 end
@@ -123,6 +129,7 @@ function love.draw()
123129 if GameClient .currentGameState == GameClient .states .SERVER_DISCONNECT then
124130 love .graphics .printf (" Disconnected from server.. Game will close soon!" , Fonts .l , 0 , 50 , love .graphics .getWidth (), " center" )
125131 end
132+ love .graphics .printf (" Press escape to quit" , Fonts .xs , 0 , 5 , love .graphics .getWidth (), " center" )
126133end
127134
128135function love .keypressed (key )
@@ -132,9 +139,13 @@ function love.keypressed(key)
132139 timestamp = love .timer .getTime (),
133140 })
134141 else
135- GameClient :resetGame ()
136- GameClient .currentGameState = GameClient .states .CLIENT_PLAY
142+ if GameClient .currentGameState == GameClient .states .GAME_END then
143+ GameClient :resetGame ()
144+ GameClient .currentGameState = GameClient .states .CLIENT_PLAY
145+ end
137146 end
147+ elseif key == " escape" then
148+ love .event .quit ()
138149 end
139150end
140151
@@ -145,8 +156,8 @@ function love.keyreleased(key)
145156end
146157
147158function love .quit ()
148- print (" Thanks for playing!" )
149- if GameClient .client then
150- GameClient .client :disconnectNow ()
151- end
159+ print (" Thanks for playing!" )
160+ if GameClient .client then
161+ GameClient .client :disconnectNow ()
162+ end
152163end
0 commit comments