Computer Science Canada

Character walking effect for side-scroller

Author:  adam_abm [ Thu Jun 05, 2003 10:42 pm ]
Post subject:  Character walking effect for side-scroller

hey
i'm making a side scroller and wondered if anybody could help me out on how to alternate the pics to give a walking effect while using the Input.Keydown method of character control.

thanks for the help

Author:  Martin [ Thu Jun 05, 2003 11:00 pm ]
Post subject: 

Here it is, you can simplify them with arrays if you want.

code:
var pic1 := Pic.FileNew ("step1.bmp")
var pic2 := Pic.FileNew ("step2.bmp")
var pic3 := Pic.FileNew ("step3.bmp")
var pic4 := Pic.FileNew ("step4.bmp")

var x : int := 50
var step := 1 %What step the player is at
var ch : string(1)
loop
    getch(ch)
    if ch = KEY_RIGHT_ARROW then
        if step = 1 then
            Pic.Draw (pic1, x, 100, picCopy)
         elsif step = 2 then
            Pic.Draw (pic2, x, 100, picCopy)
         elsif step = 3 then
            Pic.Draw (pic3, x, 100, picCopy)
         elsif step = 4 then
            Pic.Draw (pic4, x, 100, picCopy)
         end if
         step := step + 1
         x := x + 10
         if step = 5 then
             step := 1
         end if
    end if
end loop

Author:  adam_abm [ Fri Jun 06, 2003 10:29 pm ]
Post subject: 

Thanks for the code but i'm using the Input.KeyDown command and if i use your way the guy just contantly flashes through the steps (because theres no getch) I know theres a way to do it using the Input.KeyDown command so post if you got time and know the way.

thanks

Author:  Mephi [ Fri Jun 06, 2003 10:47 pm ]
Post subject: 

just building on the other code:
code:
var pic1 := Pic.FileNew ("step1.bmp")
var pic2 := Pic.FileNew ("step2.bmp")
var pic3 := Pic.FileNew ("step3.bmp")
var pic4 := Pic.FileNew ("step4.bmp")

var x : int := 50
var step := 1 %What step the player is at
var ch : array char of boolean
loop
    Input.KeyDown (ch)
    if ch (KEY_RIGHT_ARROW) then
        if step = 1 then
            Pic.Draw (pic1, x, 100, picCopy)
         elsif step = 2 then
            Pic.Draw (pic2, x, 100, picCopy)
         elsif step = 3 then
            Pic.Draw (pic3, x, 100, picCopy)
         elsif step = 4 then
            Pic.Draw (pic4, x, 100, picCopy)
         end if
         step := step + 1
         x := x + 10
         if step = 5 then
             step := 1
         end if
    end if
end loop


basically the same thing, just change to input.keydown

Author:  JayLo [ Tue Jun 17, 2003 5:48 pm ]
Post subject: 

oh man. lol according to the turing manual, GIFs should be in Turing, which would render most of this useless.

Author:  Andy [ Tue Jun 17, 2003 6:06 pm ]
Post subject: 

according to the turing manual, sprites work and its the best language and that tom west is a genius

Author:  JayLo [ Tue Jun 17, 2003 6:06 pm ]
Post subject: 

according to the turing manual, it's a party!

Author:  Andy [ Tue Jun 17, 2003 6:06 pm ]
Post subject: 

but ya if GIF works in turing, i'd be awsome cause then you can import animated pics

Author:  JayLo [ Tue Jun 17, 2003 6:08 pm ]
Post subject: 

well. tom west SAYS june 2003, but it's prolly not likely.

Author:  Andy [ Tue Jun 17, 2003 6:12 pm ]
Post subject: 

tom west is a big fag, lazy bum

Author:  JayLo [ Tue Jun 17, 2003 6:35 pm ]
Post subject: 

agreed, but 'beggars can't be choosers'.

Author:  Andy [ Wed Jun 18, 2003 10:33 am ]
Post subject: 

lol true, if you complain to him about how crap turing is he doesn't reply, but if you report a bug he replys right away asking how he can recreate the bug

Author:  PaddyLong [ Wed Jun 18, 2003 11:57 am ]
Post subject: 

probably because it is more important to make what you have now working entirely than making turing better as a whole as you seem so bent on doing... really turing isn't meant to make retail programs or anything, just for learning. if you want a better language, learn something like C++ or Java. but please stop whining about how bad turing is or whatever it is you think is wrong with it. it does what it was created to do just fine.

Author:  JayLo [ Wed Jun 18, 2003 1:25 pm ]
Post subject: 

i guess. okay paddy. challenge accepted.

Author:  Andy [ Wed Jun 18, 2003 3:06 pm ]
Post subject: 

wha? what challange? what's going on? is it me or is anyone else confused?

Author:  JayLo [ Wed Jun 18, 2003 3:52 pm ]
Post subject: 

the challenge to get out of the turing 'rut' and move on.

Author:  PaddyLong [ Wed Jun 18, 2003 6:00 pm ]
Post subject: 

it's not that I'm challenging you to stop using turing, just asking you (not necesarily you Jay Lo, but people in general..) to stop whining about it

Author:  JayLo [ Wed Jun 18, 2003 6:01 pm ]
Post subject: 

ya, but you're right. i'm so addicted to turing syntax...

Author:  Andy [ Wed Jun 18, 2003 6:10 pm ]
Post subject: 

lol ya i wrote so many compsci tests, i for got how to write the multiplication sign, i keep on writing astricks on my science tests

Author:  PaddyLong [ Wed Jun 18, 2003 6:17 pm ]
Post subject: 

I just use a dot for when I'm writing multiplication... x's can get confusing when you're working with variable x

Author:  Andy [ Wed Jun 18, 2003 6:18 pm ]
Post subject: 

but its sceince, not math, and science teachers like to use X and plus there are plenty of other variables to use

Author:  PaddyLong [ Wed Jun 18, 2003 6:23 pm ]
Post subject: 

x is a pretty standard one, especially when talking about graphs

Author:  JayLo [ Wed Jun 18, 2003 6:24 pm ]
Post subject: 

x, y, a, b
that's all i ever hope to use.

Author:  Andy [ Wed Jun 18, 2003 6:32 pm ]
Post subject: 

what about theta and alpha for angles?

Author:  PaddyLong [ Wed Jun 18, 2003 6:34 pm ]
Post subject: 

and z, i, j, k for vectors and 3 space

Author:  Andy [ Wed Jun 18, 2003 6:35 pm ]
Post subject: 

3 spaces wha?

Author:  PaddyLong [ Wed Jun 18, 2003 6:38 pm ]
Post subject: 

3d plane, x, y, z (you're probably used to 2 space, x, y)
i, j, k are unit vectors for planes x,y,z respectively... in algeo you don't look at points in a plane as just points, you look at them as vectors...
so like point (x, y, z) is actually a linear combination of vectors i, j, k so it is actually vector OP = xi + yj + zk

Author:  Andy [ Wed Jun 18, 2003 6:39 pm ]
Post subject: 

o u know i'm not a moron, i didn't know what u meant about 3 spaces, i thought u were talking about " "

Author:  Mephi [ Wed Jun 18, 2003 6:43 pm ]
Post subject: 

isnt that just one space? three spaces is more like this: " "

Author:  PaddyLong [ Wed Jun 18, 2003 6:52 pm ]
Post subject: 

lol, html doesn't display extra spaces unless you use & nbsp; "   "

Author:  krishon [ Thu Jun 19, 2003 9:51 am ]
Post subject: 

ye...that's true, its so stupid, i dun't y they made it like that


: