MrKris1224 Posted July 18, 2017 Posted July 18, 2017 (edited) Hi, I making game on own graphical engine (using GDI+) and i have some problem with keyboard steering, I using _IsPressed function. The problem is _IsPressed detect keys only when i move my mouse. When I don't moving mouse _ispressed don't works... I have function (In engine) called _GetKey - it return when player press key listed in array - removed code- What's wrong with my function? I using it in main game loop: expandcollapse popupWhile GUIGetMsg() <> $GUI_EVENT_CLOSE ; Main game loop PlayerMove() ; Player keyboard steering MouseControl() ; Mouse stering ;(...) Sleep(5) WEnd ;(...) Func PlayerMove() Local $cKey = _GetKey(5) ;(...) Switch $cKey Case "w" If MapOffset(0, -1) Then $oOffset.Y = $io1 $oOffset.Direction = $io1 EndIf Case "s" If MapOffset(0, 1) Then $oOffset.Y = $io2 $oOffset.Direction = $io2 EndIf Case "a" If MapOffset(-1, 0) Then $oOffset.X = $io1 $oOffset.Direction = $io1 EndIf Case "d" If MapOffset(1, 0) Then $oOffset.X = $io2 $oOffset.Direction = $io2 EndIf EndSwitch EndFunc And only when i move my mouse keys are detected. What is that? Bug or something? I'm using Windows 8.1 (In codes i write ";(...)" there are other game functions but not important) Edited July 18, 2017 by Jos
TwistedXion Posted July 18, 2017 Posted July 18, 2017 what is $io1 and $io2, they could be your problem?
MrKris1224 Posted July 18, 2017 Author Posted July 18, 2017 (edited) It's value how much script adding to offset (smooth moving) it isn't important. I can just directlu place $oPlayer.posX += without offset. You know. $io1 and $io2 its value 12/-12 script adding 12 or -12 pixels to offset when it reach 48 or -48 (block in game size in pixels) then player position is changed. But for now there is problem in _GetKey() or _ispressed i don't know... $cKey = _GetKey(5) ToolTip($cKey, 0, 0) Tooltip shows key only when i moving mouse and press key at the same time. When i dont move mouse tooltip shows nothing ( "" From _GetKey() ) Edited July 18, 2017 by MrKris1224
InunoTaishou Posted July 18, 2017 Posted July 18, 2017 Maybe look at WM_KEYDOWN and WM_MOUSEMOVE instead of using _IsPressed to detect when keys are pressed or the mouse is moved.
TwistedXion Posted July 18, 2017 Posted July 18, 2017 (edited) $aChrs = StringSplit("0:1:2:3:4:5:6:7:8:9:a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:w:x:y:z", ":"), _ You have a syntax error on this line I think it should be $aChrs = StringSplit("0:1:2:3:4:5:6:7:8:9:a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:w:x:y:z", ":") unless there is some purpous for the , _ at the end of that line? Edited July 18, 2017 by TwistedXion
MrKris1224 Posted July 18, 2017 Author Posted July 18, 2017 keybaord hook? I tried but it's slower for me. I tried gui accelerators and it's fine but accelerators have anoying delay betwen key detects
MrKris1224 Posted July 18, 2017 Author Posted July 18, 2017 On 7/18/2017 at 5:01 PM, TwistedXion said: $aChrs = StringSplit("0:1:2:3:4:5:6:7:8:9:a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:w:x:y:z", ":"), _ You have a syntax error on this line I think it should be $aChrs = StringSplit("0:1:2:3:4:5:6:7:8:9:a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:w:x:y:z", ":") unless there is some purpous for the , _ at the end of that line? Expand It isn't syntax error check that: Global $variable = 1, $var = 2, _ $varrrr = 3, _ $variableee = 4 It working normaly
MrKris1224 Posted July 18, 2017 Author Posted July 18, 2017 On 7/18/2017 at 5:06 PM, TwistedXion said: When I run SyntaxCheck prod Expand Instert two lines in code ;) $aChrs = StringSplit("0:1:2:3:4:5:6:7:8:9:a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:w:x:y:z", ":"), _ $aDecs = StringSplit("30:31:32:33:34:35:36:37:38:39:41:42:43:44:45:46:47:48:49:4A:4B:4C:4D:4E:4F:50:51:52:53:54:55:56:57:58:59:5A", ":")
Developers Jos Posted July 18, 2017 Developers Posted July 18, 2017 On 7/18/2017 at 5:07 PM, MrKris1224 said: Instert two lines in code Expand It still is a syntax error on line1! Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
MrKris1224 Posted July 18, 2017 Author Posted July 18, 2017 (edited) On 7/18/2017 at 5:09 PM, Jos said: It still is a syntax error on line1! Jos Expand Ohh... Really? I think NO. Edited July 18, 2017 by Jos
TwistedXion Posted July 18, 2017 Posted July 18, 2017 (edited) I still get the error. Just try taking the ,_ off and see if it works if not there is no harm Edited July 18, 2017 by Jos
Developers Jos Posted July 18, 2017 Developers Posted July 18, 2017 Oh yes there is as the comma and _ (line continuation) do not surve a purpose and is flagged as such by au3check. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
MrKris1224 Posted July 18, 2017 Author Posted July 18, 2017 (edited) On 7/18/2017 at 5:13 PM, TwistedXion said: I still get the error. Just try taking the ,_ off and see if it works if not there is no harm Expand Maybe different autoit version? I have 3.3.14.2 And you ahve more errors because you dont have other code functions Edited July 18, 2017 by Jos
Moderators JLogan3o13 Posted July 18, 2017 Moderators Posted July 18, 2017 (edited) On 7/18/2017 at 5:12 PM, MrKris1224 said: Ohh... Really? I think NO. Expand Are you using the full AutoIt, with SciTE? As TwistedXion shows you above, you are incorrect. In the future, when someone with more experience on the forum, and in fact someone who has done a lot to drive the language forward, offers a suggestion you don't understand - ask for clarification rather than assuming you know what you're talking about. Edited July 18, 2017 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Developers Jos Posted July 18, 2017 Developers Posted July 18, 2017 3-1 I guess we win? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
MrKris1224 Posted July 18, 2017 Author Posted July 18, 2017 On 7/18/2017 at 5:16 PM, JLogan3o13 said: Are you using the full AutoIt, with SciTE? As TwistedXion shows you above, you are incorrect. In the future, when someone with more experience on the forum, and in fact someone who has done a lot to drive the language forward, offers a suggestion you don't understand - ask for clarification rather than assuming you know what you're talking about. Expand Yes, i have au3 + scite On 7/18/2017 at 5:17 PM, Jos said: 3-1 I guess we win? Expand propably, but it's offtop...
TwistedXion Posted July 18, 2017 Posted July 18, 2017 (edited) On 7/18/2017 at 5:15 PM, MrKris1224 said: Maybe different autoit version? I have 3.3.14.2 And you ahve more errors because you dont have other code functions Expand @MrKris1224 yes I pointed that out and no I'm using the most up to date version of autoit with SciTE4AutoIt3.exe Edited July 18, 2017 by TwistedXion
Moderators JLogan3o13 Posted July 18, 2017 Moderators Posted July 18, 2017 Then when you run CTRL + F5 it should have flagged all of those issues as it did for others. At the very least, having a continuation character at the end of a line, with no continuation, is precisely what Jos was trying to point out to you. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Developers Jos Posted July 18, 2017 Developers Posted July 18, 2017 (edited) The issue is simply... it is valid when you add the line above it as well! not just those 2 lines. Jos ps. my last (on topic) post here . On 7/18/2017 at 5:19 PM, MrKris1224 said: but it's offtop... Expand Edited July 18, 2017 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Recommended Posts