175 repeat |
175 repeat |
176 while SDL_PollEvent(@event) <> 0 do |
176 while SDL_PollEvent(@event) <> 0 do |
177 {$IFDEF TOUCHINPUT} |
177 {$IFDEF TOUCHINPUT} |
178 if (direction <> nodir) and (movedbybuttons = true) then |
178 if (direction <> nodir) and (movedbybuttons = true) then |
179 begin |
179 begin |
180 AddFileLog('* Hedgehog moving *'); |
180 WriteLnToConsole('* Hedgehog moving *'); |
181 uKeys.isWalking:= true; |
181 uKeys.isWalking:= true; |
182 if direction = left then uKeys.leftKey:= true |
182 if direction = left then uKeys.leftKey:= true |
183 else if direction = right then uKeys.rightKey:= true; |
183 else if direction = right then uKeys.rightKey:= true; |
184 end |
184 end |
185 else uKeys.isWalking:= false; |
185 else uKeys.isWalking:= false; |
194 if (event.active.state and SDL_APPINPUTFOCUS) <> 0 then |
194 if (event.active.state and SDL_APPINPUTFOCUS) <> 0 then |
195 cHasFocus:= event.active.gain = 1; |
195 cHasFocus:= event.active.gain = 1; |
196 //SDL_VIDEORESIZE: Resize(max(event.resize.w, 600), max(event.resize.h, 450)); |
196 //SDL_VIDEORESIZE: Resize(max(event.resize.w, 600), max(event.resize.h, 450)); |
197 {$IFDEF TOUCHINPUT} |
197 {$IFDEF TOUCHINPUT} |
198 SDL_MOUSEMOTION: begin |
198 SDL_MOUSEMOTION: begin |
199 AddFileLog('********************************************* motion'); |
199 WriteLnToConsole('********************************************* motion'); |
200 mouseState:= SDL_GetMouseState(0, @x, @y); |
200 mouseState:= SDL_GetMouseState(0, @x, @y); |
201 SDL_GetRelativeMouseState(0, @dx, @dy); |
201 SDL_GetRelativeMouseState(0, @dx, @dy); |
202 |
202 |
203 direction:= nodir; |
203 direction:= nodir; |
204 |
204 |
205 if boolean(mouseState) then |
205 if boolean(mouseState) then |
206 begin |
206 begin |
|
207 {$IFDEF DEBUGFILE} |
207 AddFileLog('x: ' + inttostr(x) + ' y: ' + inttostr(y) + ' dx: ' + inttostr(dx) + ' dy: ' + inttostr(dy)); |
208 AddFileLog('x: ' + inttostr(x) + ' y: ' + inttostr(y) + ' dx: ' + inttostr(dx) + ' dy: ' + inttostr(dy)); |
|
209 {$ENDIF} |
208 |
210 |
209 {* zoom slider *} |
211 {* zoom slider *} |
210 if (x <= 50) and (y <= 430) and (y > 50) then |
212 if (x <= 50) and (y <= 430) and (y > 50) then |
211 begin |
213 begin |
212 if (dy > 0) then uKeys.wheelDown:= true |
214 if (dy > 0) then uKeys.wheelDown:= true |
227 end; |
229 end; |
228 end; |
230 end; |
229 end; |
231 end; |
230 {*MoveCamera is in uWord.pas -- conflicts with other commands*} |
232 {*MoveCamera is in uWord.pas -- conflicts with other commands*} |
231 SDL_MOUSEBUTTONDOWN: begin |
233 SDL_MOUSEBUTTONDOWN: begin |
232 AddFileLog('********************************************* touch down'); |
234 WriteLnToConsole('********************************************* touch down'); |
233 |
235 |
234 mouseState:= SDL_GetMouseState(0, @x, @y); |
236 mouseState:= SDL_GetMouseState(0, @x, @y); |
235 |
237 |
236 {* attack *} |
238 {* attack *} |
237 if (x > 50) and (x <= 270) and (y <= 50) then |
239 if (x > 50) and (x <= 270) and (y <= 50) then |
238 begin |
240 begin |
239 AddFileLog('Space DOWN -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
241 WriteLnToConsole('Space DOWN -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
240 uKeys.spaceKey:= true; |
242 uKeys.spaceKey:= true; |
241 uKeys.isAttacking:= true; |
243 uKeys.isAttacking:= true; |
242 end; |
244 end; |
243 |
245 |
244 if (x <= 50) and (y <= 50) then |
246 if (x <= 50) and (y <= 50) then |
245 begin |
247 begin |
246 AddFileLog('Left Arrow Key DOWN -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
248 WriteLnToConsole('Left Arrow Key DOWN -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
247 direction:= left; |
249 direction:= left; |
248 movedbybuttons:= true; |
250 movedbybuttons:= true; |
249 end; |
251 end; |
250 |
252 |
251 if (x > 270) and (y <= 50) then |
253 if (x > 270) and (y <= 50) then |
252 begin |
254 begin |
253 AddFileLog('Right Arrow Key DOWN -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
255 WriteLnToConsole('Right Arrow Key DOWN -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
254 direction:= right; |
256 direction:= right; |
255 movedbybuttons:= true; |
257 movedbybuttons:= true; |
256 end; |
258 end; |
257 |
259 |
258 {* high jump *} |
260 {* high jump *} |
310 SDL_JOYAXISMOTION: begin |
312 SDL_JOYAXISMOTION: begin |
311 {* axis 0 = left and right; |
313 {* axis 0 = left and right; |
312 axis 1 = up and down; |
314 axis 1 = up and down; |
313 axis 2 = back and forth; *} |
315 axis 2 = back and forth; *} |
314 |
316 |
315 {$IFDEF DEBUGFILE} |
317 WriteLnToConsole('********************************************* accelerometer'); |
316 AddFileLog('********************************************* accelerometer'); |
|
317 {$ENDIF} |
|
318 |
318 |
319 tiltValue:= SDL_JoystickGetAxis(uKeys.theJoystick, 0); |
319 tiltValue:= SDL_JoystickGetAxis(uKeys.theJoystick, 0); |
320 |
320 |
321 if (CurrentTeam <> nil) then |
321 if (CurrentTeam <> nil) then |
322 begin |
322 begin |
|
323 {$IFDEF DEBUGFILE} |
323 AddFileLog('Joystick: 0; Axis: 0; Value: ' + inttostr(tiltValue)); |
324 AddFileLog('Joystick: 0; Axis: 0; Value: ' + inttostr(tiltValue)); |
|
325 {$ENDIF} |
324 |
326 |
325 if tiltValue > 1500 then |
327 if tiltValue > 1500 then |
326 begin |
328 begin |
327 uKeys.rightKey:= true; |
329 uKeys.rightKey:= true; |
328 uKeys.isWalking:= true; |
330 uKeys.isWalking:= true; |
575 LoadLocale(Pathz[ptLocale] + '/' + cLocaleFName); |
577 LoadLocale(Pathz[ptLocale] + '/' + cLocaleFName); |
576 |
578 |
577 if recordFileName = '' then |
579 if recordFileName = '' then |
578 SendIPCAndWaitReply('C') // ask for game config |
580 SendIPCAndWaitReply('C') // ask for game config |
579 else |
581 else |
580 begin |
582 LoadRecordFromFile(recordFileName); |
581 LoadRecordFromFile(recordFileName); |
|
582 end; |
|
583 |
583 |
584 s:= 'eproto ' + inttostr(cNetProtoVersion); |
584 s:= 'eproto ' + inttostr(cNetProtoVersion); |
585 SendIPCRaw(@s[0], Length(s) + 1); // send proto version |
585 SendIPCRaw(@s[0], Length(s) + 1); // send proto version |
586 |
586 |
587 InitTeams; |
587 InitTeams; |
588 AssignStores; |
588 AssignStores; |
589 |
589 |
590 if isSoundEnabled then InitSound; |
590 if isSoundEnabled then |
|
591 InitSound; |
591 |
592 |
592 StoreInit; |
593 StoreInit; |
593 |
594 |
594 isDeveloperMode:= false; |
595 isDeveloperMode:= false; |
595 |
596 |
596 TryDo(InitStepsFlags = cifAllInited, |
597 TryDo(InitStepsFlags = cifAllInited, 'Some parameters not set (flags = ' + inttostr(InitStepsFlags) + ')', true); |
597 'Some parameters not set (flags = ' + inttostr(InitStepsFlags) + ')', |
|
598 true); |
|
599 |
598 |
600 MainLoop; |
599 MainLoop; |
601 ControllerClose |
600 ControllerClose |
602 end; |
601 end; |
603 |
602 |
606 var Preview: TPreview; |
605 var Preview: TPreview; |
607 h: byte; |
606 h: byte; |
608 begin |
607 begin |
609 InitIPC; |
608 InitIPC; |
610 IPCWaitPongEvent; |
609 IPCWaitPongEvent; |
611 TryDo(InitStepsFlags = cifRandomize, |
610 TryDo(InitStepsFlags = cifRandomize, 'Some parameters not set (flags = ' + inttostr(InitStepsFlags) + ')', true); |
612 'Some parameters not set (flags = ' + inttostr(InitStepsFlags) + ')', |
|
613 true); |
|
614 |
611 |
615 Preview:= GenPreview; |
612 Preview:= GenPreview; |
616 WriteLnToConsole('Sending preview...'); |
613 WriteLnToConsole('Sending preview...'); |
617 SendIPCRaw(@Preview, sizeof(Preview)); |
614 SendIPCRaw(@Preview, sizeof(Preview)); |
618 h:= MaxHedgehogs; |
615 h:= MaxHedgehogs; |