Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / [SOLVED] Problem with Tutorial #04, the input does not work with keyboard

Author
Message
Jerry McGuire
7
Years of Service
User Offline
Joined: 25th Mar 2017
Location:
Posted: 25th Mar 2017 01:56
Hi,
I just bought AppGameKit yesterday on Steam.
I did the first three tutorials successfully These used the Joystick commands, and it was all fine. I would use the WASD keys, and they would work. (By the way, it would be nice to "control" or at least "display" the keys/input that is being used by the program )
As I was doing the 4th Tutorial, and allowed for the "PlayerMove" within the loop ( PlayerMove file #include'd of course), just like in the video. But as soon as I ran it, the "ship" would appear now right of the middle of the screen, AND (most importantly) I wasn't able to move the Sprite
I tried WASD, arrows, and all but the function keys on the keyboard, but nothing worked
What is going on?
Help!!

Win 7 Pro 64bit
AVAST antivirus

Thanks!

The author of this post has marked a post as an answer.

Go to answer

easter bunny
12
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 25th Mar 2017 06:17 Edited at: 25th Mar 2017 06:18
Is this the tutorial you're talking about?


If so, add the following lines to your main loop and see what they say:
Print(playerx)
print(GetDirectionX())

Does GetDirectionX() change when you use the left/right arrow keys? If it'll be some issue with the input. If GetDirectionX() is working, then there's an issue with your code.

Actually, it isn't likely it's a problem with GetDirectionX, try the code below first.

Sounds like the problem is most likely with the code that checks if they player has gone past the right hand side of the screen.
Check these lines in the playermove sub:

From what you've described, it seems like it's always evaluating the expression to true, and so is setting the player position to the righthand side of the screen every frame. Double check that little code block.
If that doesn't work, try the print statements I put above and see what they're saying.

My Games - Latest WIP - My Website: Immortal.Digital - FB - Twitter
130,000 installs with AppGameKit and counting
Jerry McGuire
7
Years of Service
User Offline
Joined: 25th Mar 2017
Location:
Posted: 27th Mar 2017 19:45
This post has been marked by the post author as the answer.
Yes that is the tutorial I was talking about.
I'm sorry. I figured out what was going on five minutes later, but I somehow couldn't delete the post anymore

They don't show their input on the tutorials, so you have to figure it out on your own. The very first tutorials use the WASD keys (and won't work with the arrow keys).
The "space shooter" tutorials use the arrow keys (won't work with the WASD keys) and, oddly enough, use the left mouse button instead of the "enter" key.
Personally, I think they should mention these "default" input choices explicitly in the tutorial videos; and I also think that using the arrow keys and the mouse button doesn't make sense. Either you use the mouse for both movement and shooting, or you use the keyboard for both moving and shooting.
Apparently there are commands to change this default behavior though.
Thanks for caring. I appreciate it.
easter bunny
12
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 28th Mar 2017 01:49
Quote: "but I somehow couldn't delete the post anymore "

Yeah only mods can delete threads/posts in this forum.

Quote: "They don't show their input on the tutorials, so you have to figure it out on your own. The very first tutorials use the WASD keys (and won't work with the arrow keys).
The "space shooter" tutorials use the arrow keys (won't work with the WASD keys) and, oddly enough, use the left mouse button instead of the "enter" key.
Personally, I think they should mention these "default" input choices explicitly in the tutorial videos; and I also think that using the arrow keys and the mouse button doesn't make sense. Either you use the mouse for both movement and shooting, or you use the keyboard for both moving and shooting"

Yeah I can see why that'd be confusing Although now that you know, it's probably worth having a shot at modifying the code for whatever input you so desire

Currently it uses the command GetDirectionX() which is a multiplatform command for getting the device angle. On desktops, it uses the arrow keys (returns -90 degrees for left arrow key and +90 degrees for right arrow key). But on a mobile device, it uses the actual physical angle of the phone.
You could modify the program to use the mouse position to move the spaceship (use GetRawMouseX() and check if it's less or more than the centre of the screen perhaps). You could also modify it to use any keys you want on the keyboard (use GetRawKeystate()).
Find the keycodes for each key on the keyboard with this snippet

Then once you find the keycodes for the keys you want, move the player left or right depending on the state of those particular keys.

Quote: "Thanks for caring. I appreciate it"

No problem

My Games - Latest WIP - My Website: Immortal.Digital - FB - Twitter
130,000 installs with AppGameKit and counting

Login to post a reply

Server time is: 2024-11-22 09:31:33
Your offset time is: 2024-11-22 09:31:33