Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 CHARS?
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
gohan




PostPosted: Thu Jun 02, 2005 9:14 am   Post subject: CHARS?

I would like to know what the chars for Ctrl and also for Alt???
Sponsor
Sponsor
Sponsor
sponsor
lyam_kaskade




PostPosted: Thu Jun 02, 2005 9:22 am   Post subject: (No subject)

They don't have chars. If you want to use them use Input.KeyDown[/code]
[Gandalf]




PostPosted: Thu Jun 02, 2005 11:44 pm   Post subject: (No subject)

Use KEY_CTRL and KEY_ALT when using Input.Keydown.

code:
if keys (KEY_CTRL) then
put "Ctrl has been presssed"
[/code]
gohan




PostPosted: Fri Jun 03, 2005 8:31 am   Post subject: (No subject)

Oh yeah...I forgot that I put this down....but it's here now soo...how would i use the space bar?

And can I use the shift button and use the arrow keys at the same time?
lyam_kaskade




PostPosted: Fri Jun 03, 2005 9:42 am   Post subject: (No subject)

yes.

code:

Input.KeyDown (keys)
    if keys (KEY_SHIFT) and keys (KEY_DOWN_ARROW) then
        put "yes"
    end if


I don't think theres a key for spacebar, but I could be wrong.[/code]
StarGateSG-1




PostPosted: Fri Jun 03, 2005 9:54 am   Post subject: (No subject)

Yes there is a space but it is :

code:
ORD_SPACE
gohan




PostPosted: Fri Jun 03, 2005 10:36 am   Post subject: (No subject)

Hey, how would I use the space though...because It is different then...
code:
Input.KeyDown (chars)

This code that im going to put down is for my RPG Final Project....I need help on a few things!!! I got some of the code from a tutorial...I got a little help from it!! Smile
|1| I would like to know how to use the space bar
|2| I would like to know if I can hold my SHIFT button down(Stay invisible until I let go)
|3| I would like to know if I can hold SHIFT + Arrow Keys (Move,While Inivisible)
|4| and last, and prolly not lease... I would like to keep the circle to stay on the screen!!

code:
var x, y : int
x := 4
y := 4
var bc : int := black
var chars : array char of boolean
loop
    Input.KeyDown (chars)
    drawfilloval (x, y, 4, 4, brightred)                    % IT's the character
    delay (10)
    cls
    colourback (black)
    if chars (KEY_UP_ARROW) then                            % MOVE UP
        y := y + 3
    end if
    if chars (KEY_RIGHT_ARROW) then                         % MOVE RIGHT
        x := x + 3
    end if
    if chars (KEY_LEFT_ARROW) then                          % MOVE LEFT
        x := x - 3
    end if
    if chars (KEY_DOWN_ARROW) then                          % MOVE DOWN
        y := y - 3
    end if
    if chars (KEY_ENTER) then                               % TELEPORT BACK TO START POINT
        x := 4
        y := 4
    end if
    if chars (KEY_SHIFT) then                                % TURN INVISIBLE
        for q : 1 .. 10
            drawoval (x, y, 4 + q, 4 + q, bc)
            delay (50)
        end for
    end if
    if chars (KEY_ALT) then                                 % SPECIAL FEATURE (not decided yet)
        for w : 1 .. 10
            drawoval (x, y, 4 + w, 4 + w, white)
            delay (50)
        end for
    end if
    if chars (KEY_CTRL) then                               % SPECIAL FEATURE (not decided yet)
        for e : 1 .. 10
            drawoval (x, y, 4 + e, 4 + e, white)
            delay (50)
        end for
    end if
end loop

It would be kind if some pplz would help me and all of my problems...Plzz and Thnxx
StarGateSG-1




PostPosted: Fri Jun 03, 2005 11:10 am   Post subject: (No subject)

I told you how to use space bar:

code:
ORD_SPACE


for the shift do it like this:

code:
if chars = (KEY_SHIFT) then
if invisiblity  = false
invisiblity := true
elsif invisiblity = true then
invisiblity := false
end if


if you do the invisiblity like that then you can move.

For the circle to stya on the screen just check if the cirlce radius is outsdie of the screen if it is don't let them move in that direction any more.
Sponsor
Sponsor
Sponsor
sponsor
gohan




PostPosted: Fri Jun 03, 2005 1:01 pm   Post subject: (No subject)

what would the variable be called for
code:
ORD_SPACE

Quote:
For the circle to stya on the screen just check if the cirlce radius is outsdie of the screen if it is don't let them move in that direction any more.

I not sure what you mean??? Confused
but thnx for the invisibility tip!!
lyam_kaskade




PostPosted: Fri Jun 03, 2005 1:20 pm   Post subject: (No subject)

Check to make sure the radius of the circle (4) is not outside the boundaries of the screen (maxx and maxy)
ie.
code:

x+4 <maxx and x-4>maxx
y+4 <maxy and y-4>maxy


If it is outside the screen boundaries then just keep x or y from increasing.
[Gandalf]




PostPosted: Fri Jun 03, 2005 3:21 pm   Post subject: (No subject)

Ahh, I was going to post this in my example code, but I was feeling lazy...

The easiest way of detecting the spacebar key is:
code:
if keys (' ') then
   put "Space Bar has been presssed"

The '' signs mean that the character inside is what will be detected, if the key does have a character. Like so:
code:
if keys ('a') then
   put "a has been pressed"
elsif keys (KEY_CTRL) then
   put "The ctrl key has been pressed."
end if
syphon4




PostPosted: Fri Jun 03, 2005 3:44 pm   Post subject: chars

here man this program tells you all the chars


var keys : array 0 .. * of
record
character : char
name : string
end record := init (
init (chr (27), "Escape key"),
init (chr (187), "F1 key"),
init (chr (188), "F2 key"),
init (chr (189), "F3 key"),
init (chr (190), "F4 key"),
init (chr (191), "F5 key"),
init (chr (192), "F6 key"),
init (chr (193), "F7 key"),
init (chr (194), "F8 key"),
init (chr (195), "F9 key"),
init (chr (196), "F10 key"),
init (chr (133), "F11 key"),
init (chr (134), "F12 key"),
init (chr (10), "Enter key"),
init (chr (180), "Shift key"),
init (chr (181), "Control key"),
init (chr (182), "Alt key"),
init (chr (8), "Backspace key"),
init (chr (9), "Tab key"),
init (chr (203), "Left Arrow"),
init (chr (200), "Up Arrow"),
init (chr (205), "Right Arrow"),
init (chr (208), "Down Arrow"),
init (chr (199), "Home"),
init (chr (201), "Page Up"),
init (chr (207), "End"),
init (chr (209), "Page Down"),
init (chr (210), "Insert"),
init (chr (211), "Delete"),
init (chr (183), "Keypad 5"),

init ('`', "Left apostrophe key"),
init ('1', "1 key"),
init ('2', "2 key"),
init ('3', "3 key"),
init ('4', "4 key"),
init ('5', "5 key"),
init ('6', "6 key"),
init ('7', "7 key"),
init ('8', "8 key"),
init ('9', "9 key"),
init ('0', "0 key"),
init ('-', "- key"),
init ('=', "= key"),
init ('a', "a key"),
init ('b', "b key"),
init ('c', "c key"),
init ('d', "d key"),
init ('e', "e key"),
init ('f', "f key"),
init ('g', "g key"),
init ('h', "h key"),
init ('i', "i key"),
init ('j', "j key"),
init ('k', "k key"),
init ('l', "l key"),
init ('m', "m key"),
init ('n', "n key"),
init ('o', "o key"),
init ('p', "p key"),
init ('q', "q key"),
init ('r', "r key"),
init ('s', "s key"),
init ('t', "t key"),
init ('u', "u key"),
init ('v', "v key"),
init ('w', "w key"),
init ('x', "x key"),
init ('y', "y key"),
init ('z', "z key"),
init ('[', "[ key"),
init (']', "] key"),
init ('\\', "\\ key"),
init (';', "; key"),
init ('\'', "' key"),
init (',', ", key"),
init ('.', ". key"),
init ('/', "/ key"),
init (' ', "Space key"),
init ('*', "* key (Keypad)"),
init ('+', "+ key (Keypad)")
)
var a : array char of boolean
setscreen ("noecho")
loop
Input.KeyDown (a)

locate (1, 1)
for key : 0 .. upper (keys)
if a (keys (key).character) then
put ord (keys (key).character), ": ", keys (key).name, " " ..
end if
end for
put ""
end loop


..............and culd anyone make me a good luigi character and give me the code plz and thank you
Bacchus




PostPosted: Sat Jun 04, 2005 12:38 am   Post subject: (No subject)

Bloody Hell, if you really want a good Luigi, just learn how to use Pictures!

gohan wrote:
|1| I would like to know how to use the space bar
|2| I would like to know if I can hold my SHIFT button down(Stay invisible until I let go)
|3| I would like to know if I can hold SHIFT + Arrow Keys (Move,While Inivisible)
|4| and last, and prolly not lease... I would like to keep the circle to stay on the screen!!


|1| Gandalf had it right its just ' ', like any other key that returns a character.
|2| In your main loop just have a check to see if the key is down.
code:

loop
  Input.KeyDown(chars)

  if chars(KEY_SHIFT) then
    invis:=true
  else
    invis:=false
  end if

  if ~invis then
    draw.character
  end if
end loop

|3| Stick the Keys in different If statments, it will get them all.
|4| 2 ways, Either when you draw the cirlce check to see if it would be below 0 or above the maxx/maxy and draw it inside. Or do a check when they press a button and don't change the x/y if it would go out.
gohan




PostPosted: Mon Jun 06, 2005 8:53 am   Post subject: (No subject)

Quote:
Bloody Hell, if you really want a good Luigi, just learn how to use Pictures!

What the heck is that??

|1| check
|2| no check (what kind of var would be invis?)
|3| no check (I can't get the circle to move, while invisible)
|4| no check (I still don't get how to keep my circle to stay on the screen)
Bacchus




PostPosted: Mon Jun 06, 2005 3:09 pm   Post subject: (No subject)

lol That was for syphon4, not you.

Here like this:
code:
setscreen ("graphics,offscreenonly")
var x, y : int := 20
var invis : boolean := false
var chars : array char of boolean

loop
    cls
    Input.KeyDown (chars)

    invis := false

    if chars (' ') then
        invis := true
    end if

    if chars (KEY_RIGHT_ARROW) & x + 5 <= maxx then
        x += 5
    elsif chars (KEY_LEFT_ARROW) & x - 5 >= 0 then
        x -= 5
    end if

    if chars (KEY_UP_ARROW) & y + 5 <= maxy then
        y += 5
    elsif chars (KEY_DOWN_ARROW) & y - 5 >= 0 then
        y -= 5
    end if

    if ~invis then
        drawfilloval (x, y, 5, 5, 2)
    end if
    View.Update
    delay (10)
end loop
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 16 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: