Here is a code:Code: QB64: [Select]
_TITLE "A Promising Game!" restart: x = 200 y = 200 gravity = 9.8 makechar y = y - 25 y_change = y_change + 1 y = y + gravity y = y + 25 y_change = y_change + 1 y = y + gravity x = x - 10 x = x + 10 y = y + gravity 'Blocks 'LINE (100, 400)-STEP(200, 50), _RGB32(255, 83, 33), BF 'IF collision%(x, y, 20, 20, 100, 400, 200, 50) THEN ' y = oldy ' y_change = 0 ' gravity = 0 'ELSE ' gravity = 9.8 ' oldy = y 'END IF makeobs 100, 400 _LIMIT 60 SUB makechar collision% = 0 collision% = 1 y = oldy gravity = 0 y_change = 0 oldy = y gravity = 9.8
What is the bug that brings the player to it's initial position?
Alright, another question!
When I press the upper arrow key and the left arrow key at the same time, only the upper arrow key works but not the left arrow key. What is causing it and How do I solve it? HELP!
-Prithak
It’s because the _KEYDOWN check is in an ELSEIF statement. Make all those become independent IF checks instead.
Here is a code:Code: QB64: [Select]
_TITLE "A Promising Game!" restart: x = 200 y = 200 gravity = 9.8 makechar y = y - 25 y_change = y_change + 1 y = y + gravity y = y + 25 y_change = y_change + 1 y = y + gravity x = x - 10 x = x + 10 y = y + gravity 'Blocks 'LINE (100, 400)-STEP(200, 50), _RGB32(255, 83, 33), BF 'IF collision%(x, y, 20, 20, 100, 400, 200, 50) THEN ' y = oldy ' y_change = 0 ' gravity = 0 'ELSE ' gravity = 9.8 ' oldy = y 'END IF makeobs 100, 400 _LIMIT 60 SUB makechar collision% = 0 collision% = 1 y = oldy gravity = 0 y_change = 0 oldy = y gravity = 9.8
What is the bug that brings the player to it's initial position?
It’s because the _KEYDOWN check gimp (https://gimp.software/) freejobalert (https://freejobalert.vip/) notepad++ (https://notepad.software/) is in an ELSEIF statement. Make all those become independent IF checks instead.Thanks Both of you for this. I was also facing the same and happened to find this has already been answered.