Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - jhain

Pages: [1]
1
Hi, I'm working on a basic game and can't figure out how to get player input to register.

I'm using sf::Event::KeyPressed with switch(event.key.code) to control WASD movement (top down grid-based turn-based dungeon crawler style) within the main window.pollEvent(event) and got it to work without errors.

I want to press another key to throw an item, but I can't figure out how to trigger another WASD switch for direction of the throw. Here's the broken code I have so far:


(click to show/hide)

I got it to work using cin, but how would I get it to work in the window itself? I understand it's just skipping over the inner if statement. I believe I need to involve another Event but I'm scratching my head. Should I be relocating all of the movement/input keys outside of the while (window.pollEvent(event)) statement? I've read the Event / Input / Keyboard tutorial pages multiple times but still need some help!

First post! Haven't been using SFML very long and rusty with C++ so bear with me :)

Pages: [1]
anything