
-----------------------------------
amz_best
Tue Sep 09, 2014 8:27 pm

How to change controls for a game.....
-----------------------------------
What is it you are trying to achieve?
The ability to change controls in a game

for example:


Input.KeyDown (blah)
     if (KEY_BLAH) then
       blah = true
      end if

%to something like

Input.KeyDown (blah)
    if (Button chosen) then
        blah = true
    end if


What is the problem you are having?
I HAVE ABSOLUTELY NO IDEA HOW TO ACHIEVE IT.


Describe what you have tried to solve this problem
N/A


Please specify what version of Turing you are using
Open turing 1.0

-----------------------------------
Tony
Tue Sep 09, 2014 9:11 pm

RE:How to change controls for a game.....
-----------------------------------
Oh, you must have some idea... you are half way there!
[code]
Input.KeyDown (blah) 
     if (KEY_BLAH) then 
       blah = true 
      end if 
[/code]

What's the type and value of KEY_BLAH?

Reading through documentation is typically the first step to understanding what's going on -- [tdoc]Input.KeyDown[/tdoc]

-----------------------------------
amz_best
Tue Sep 09, 2014 9:38 pm

RE:How to change controls for a game.....
-----------------------------------
^Not exactly, i've already gotten dat far xD
what im looking for is a way to change (key_blah) to something else, like in a game, you change the moving up button to "w" instead of "KEY_UP_ARROW", YEAH, i wasnt clear... but dat is wat im looking for
ofcourse, while code is running, without closnig and re changing code...

-----------------------------------
Tony
Wed Sep 10, 2014 1:19 am

RE:How to change controls for a game.....
-----------------------------------
KEY_UP_ARROW is a constant, which has some value.
[code]
put KEY_UP_ARROW
[/code]

-----------------------------------
amz_best
Wed Sep 10, 2014 10:11 am

Re: How to change controls for a game.....
-----------------------------------


var UAK : string :=  KEY_UP_ARROW
var control : array char of boolean

put "Up arrow key?"..
get UAK


loop
Input.KeyDown (control)

if control (UAK) then
Draw.FillBox (0, 0, maxx, maxy, black)
end if
end loop






^This code will not work...


i need an idea of a way to change the CONTROL of moving a player to something else without closing turing and reprogramming.

-----------------------------------
Dreadnought
Wed Sep 10, 2014 10:15 pm

Re: How to change controls for a game.....
-----------------------------------
What is the type of UAK?
Can you use that type for the index of an array?

-----------------------------------
amz_best
Sat Sep 13, 2014 6:35 pm

RE:How to change controls for a game.....
-----------------------------------
i am fairly new sir... and i can say... idk wtf u just said. But i found something out about these "ch" and "char" variables and i might be able 2 get it working!

-----------------------------------
Dreadnought
Sat Sep 13, 2014 9:38 pm

Re: How to change controls for a game.....
-----------------------------------
So var UAK : char := KEY_UP_ARROW
var control : array char of boolean

put "Up arrow key?" ..
%UAK := getchar()
get UAK


loop
    Input.KeyDown (control)

    if control (UAK) then
        Draw.FillBox (0, 0, maxx, maxy, black)
    end if
end loop

Hey it works! kinda....
When we hit a key (like the up arrow) the key we pressed is printed (for the up arrow it prints E with an acute accent) and then we have to press ENTER. You might say "Bah, I can work with this", but we can do better.

Enter the loop
    var ch : char
    ch := Input.getchar ()

    % Wait a bit so we don't spam the window
    Time.Delay (50)

    put "You entered:", ch
end loop

Hopefully this is more helpful than my previous post.

-----------------------------------
amz_best
Fri Sep 19, 2014 7:11 pm

RE:How to change controls for a game.....
-----------------------------------

%-Declare vars-%
%--------------------------------
var y : int := 100              %
var gottenCH: boolean:= false   %
var ch : char                   %
%--------------------------------

loop 

    %get only a button
    if gottenCH = false then
    put "Enter Move Circle Up: "..
    ch := Input.getchar ()
    gottenCH := true
    end if 
    
    
    Time.Delay (50)  
    drawoval (100, y, 100, 100, blue)
    
    %i didnt think dis would work lol
    if ch = Input.getchar () then
    y += 1
    end if
    
end loop




EDIT: I GOT IT 2 WORK XD yay lol but i idk how to make it moar than 1 char... BTW, i used ur code and made it work for only  1 button, but i need moar "1 buttons"....
