How do I control sprite with keyboard input?

0 favourites
  • 5 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • i really like this construct games called little office trouble

    scirra.com/arcade/action-games/littleofficetrouble-15

    i want to create a game with similar mechanics with this game i wonder how to make a sprite like the loading bar in that game to start randomly but reversed everytime you click the keyboard

    i am very very noob, i only know how to make shooting game and basic platformer

    so i was really hoping somebody could help me,thanks if u r reading this

    Tagged:

  • there is some math involved... but it's only 2 events.

    you need:

    -the full length of the bar graphic

    -a variable that holds the max value of your bar

    -a variable that holds the current bar value

    Event: Every Tick

    Action: Set bar_graphic Width to: bar_value * (bar_fullwidth / max_bar_value)

    Event: OnKey pressed

    Action: Add 1 to bar_value

    You can use max/min in the equation to prevent you from going over the max or minimum width

  • thank youuu soo much ,ill try it out

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • i was actually looking to subtract value from my keyboard input like the game ,so i was wondering how to add value every x seconds but make it speeds up (to every 0.1 second), do u know how to do that

  • there are two things going on in that game for the progress bars

    by itself the bar is adding value so:

    Event On Start:
    	Action: time_elapsed = 0
    	Action: max_time = 10
    
    Event: Every Tick
    	Action: Add dt to time_elapsed
    	Action: Set bar_graphic Width to: time_elapsed * (bar_fullwidth / max_time)
    
    Event: OnKey pressed
    	Action: Subtract X from time_elapsed
    

    So they have ten seconds without typing before the bar reaches it's max. Then to make the game harder you would set max_time to a shorter interval

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)