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

Username:   Password: 
 RegisterRegister   
 making boundries
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
roosterfest123




PostPosted: Tue Jun 07, 2011 3:40 pm   Post subject: making boundries

hey im making a street fighter game and i cant figure out how to make boundries so that my guy doesnt walk back through the screen, does anyone know how to make a boudry for this situation?
Sponsor
Sponsor
Sponsor
sponsor
Raknarg




PostPosted: Tue Jun 07, 2011 3:46 pm   Post subject: RE:making boundries

Turing:

if key (KEY_LEFT_ARROW) and x > 0 then
     x := x - 1
end if
roosterfest123




PostPosted: Tue Jun 07, 2011 3:53 pm   Post subject: RE:making boundries

i just tried it and he still goes through it heres the code maybe u know what im doing wrong
View.Set ("offscreenonly")
setscreen ("graphics:max;678;nobuttonbar")
var punch,jump1,kick, man2, man3, man4,duck, hit1 : int
var man5 : int
var background : int
var count : boolean
var keys : array char of boolean
var x := 1
var y := 1
background := Pic.FileNew ("background.bmp")
jump1 := Pic.FileNew ("jump.bmp")
man2 := Pic.FileNew ("man2.bmp")
duck := Pic.FileNew ("duck.bmp")
man3 := Pic.FileNew ("man3.bmp")
kick := Pic.FileNew ("kick.bmp")
man4 := Pic.FileNew ("man4.bmp")
man5 := Pic.FileNew ("man 5.bmp")
hit1 := Pic.FileNew ("hit1.bmp")
punch := Pic.FileNew ("punch.bmp")
procedure walkRight
for i : 1 .. 2
x := x + 70
cls
Pic.Draw (background, 1, 1, picXor)
Pic.Draw (man4, x, y, picMerge)
View.Update
end for
end walkRight
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure walkLeft
for i : 1 .. 2
x := x - 70
cls
Pic.Draw (background, 1, 1, picXor)
Pic.Draw (man4, x, y, picMerge)
View.Update
end for
end walkLeft

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure jump
for i : 1 .. 15
y := y + 15
cls
Pic.Draw (background, 1, 1, picXor)
Pic.Draw (jump1, x, y, picMerge)
View.Update
end for
for i : 1 .. 15
y := y - 15
cls
Pic.Draw (background, 1, 1, picXor)
Pic.Draw (jump1, x, y, picMerge)
View.Update
end for
end jump
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure jump2
for i : 1 .. 15
y := y + 15
x := x + 9
cls
Pic.Draw (background, 1, 1, picXor)
Pic.Draw (jump1, x, y, picMerge)
View.Update
end for
for i : 1 .. 15
y := y - 15
x := x + 10
cls
Pic.Draw (background, 1, 1, picXor)
Pic.Draw (jump1, x, y, picMerge)
View.Update
end for
end jump2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure jump3
for i : 1 .. 15
y := y + 15
x := x - 9
cls
Pic.Draw (background, 1, 1, picXor)
Pic.Draw (jump1, x, y, picMerge)
View.Update
end for
for i : 1 .. 15
y := y - 15
x := x - 10
cls
Pic.Draw (background, 1, 1, picXor)
Pic.Draw (jump1, x, y, picMerge)
View.Update
end for
end jump3

loop

Pic.Draw (jump1, x, y, picMerge)
Input.KeyDown (keys)
if keys (KEY_UP_ARROW) then
jump
end if
if keys (KEY_RIGHT_ARROW) then
delay (100)
walkRight
delay(50)
Pic.Draw (man5, x, y, picMerge)
end if

if keys (KEY_LEFT_ARROW) then
delay (100)
walkLeft
delay (50)
Pic.Draw (man5, x, y, picMerge)
end if
if keys (KEY_LEFT_ARROW) and x > 0 then
x := x + 1
end if
cls
Pic.Draw (background, 1, 1, picXor)
Pic.Draw (man5, x, y, picMerge)
if keys ('1') then
cls
Pic.Draw (background, 1, 1, picXor)
Pic.Draw (hit1, x, y, picMerge)
end if
if keys ('e') then
jump2
end if
if keys ('q') then
jump3
end if
if keys ('2') then
cls
Pic.Draw (background, 1, 1, picXor)
Pic.Draw (punch, x, y, picMerge)
end if
if keys ('3') then
cls
Pic.Draw (background, 1, 1, picXor)
Pic.Draw (kick, x, y, picMerge)
end if
if keys (KEY_DOWN_ARROW) then
cls
Pic.Draw (background, 1, 1, picXor)
Pic.Draw (duck, x, y, picMerge)
end if
View.Update
end loop
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Raknarg




PostPosted: Tue Jun 07, 2011 5:48 pm   Post subject: RE:making boundries

Could you attach the pictures?

So why do you use a procedure for walking left and right?
Tony




PostPosted: Tue Jun 07, 2011 5:51 pm   Post subject: Re: RE:making boundries

roosterfest123 @ Tue Jun 07, 2011 3:53 pm wrote:

if keys (KEY_LEFT_ARROW) then
delay (100)
walkLeft
delay (50)
Pic.Draw (man5, x, y, picMerge)
end if
if keys (KEY_LEFT_ARROW) and x > 0 then
x := x + 1
end if
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Raknarg




PostPosted: Tue Jun 07, 2011 6:03 pm   Post subject: RE:making boundries

good call, didn't see that. It's going left twice.
apython1992




PostPosted: Tue Jun 07, 2011 6:55 pm   Post subject: RE:making boundries

Also, if I may pop in here - use syntax tags in the future.

code:
[syntax="turing"]put "Welcome!"[/syntax]


Turing:
put "Welcome!"
Raknarg




PostPosted: Tue Jun 07, 2011 7:03 pm   Post subject: RE:making boundries

Wait, it's not going left twice. It's calling the walkleft procedure, which indefinitely goes left, then activating the other left command, which actually goes RIGHT. You should get rid of the procedures, I don't think you need them.
Sponsor
Sponsor
Sponsor
sponsor
Raknarg




PostPosted: Tue Jun 07, 2011 7:04 pm   Post subject: RE:making boundries

The walk left and right ones, I mean.
roosterfest123




PostPosted: Tue Jun 07, 2011 7:49 pm   Post subject: RE:making boundries

i just tried taking away the procedures and puting in the
if key (KEY_LEFT_ARROW) and x > 0 then
x := x - 1
end if
and it still didn't work
apython1992




PostPosted: Tue Jun 07, 2011 8:01 pm   Post subject: RE:making boundries

Can you post your update code using the syntax tags I showed you?
roosterfest123




PostPosted: Tue Jun 07, 2011 8:03 pm   Post subject: RE:making boundries

View.Set ("offscreenonly")
setscreen ("graphics:max;678;nobuttonbar")
var punch,jump1,kick, man2, man3, man4,duck, hit1 : int
var man5 : int
var background : int
var count : boolean
var keys : array char of boolean
var x := 1
var y := 1
background := Pic.FileNew ("background.bmp")
jump1 := Pic.FileNew ("jump.bmp")
man2 := Pic.FileNew ("man2.bmp")
duck := Pic.FileNew ("duck.bmp")
man3 := Pic.FileNew ("man3.bmp")
kick := Pic.FileNew ("kick.bmp")
man4 := Pic.FileNew ("man4.bmp")
man5 := Pic.FileNew ("man 5.bmp")
hit1 := Pic.FileNew ("hit1.bmp")
punch := Pic.FileNew ("punch.bmp")
procedure walkRight
for i : 1 .. 2
x := x + 70
cls
Pic.Draw (background, 1, 1, picXor)
Pic.Draw (man4, x, y, picMerge)
View.Update
end for
end walkRight
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure jump
for i : 1 .. 15
y := y + 15
cls
Pic.Draw (background, 1, 1, picXor)
Pic.Draw (jump1, x, y, picMerge)
View.Update
end for
for i : 1 .. 15
y := y - 15
cls
Pic.Draw (background, 1, 1, picXor)
Pic.Draw (jump1, x, y, picMerge)
View.Update
end for
end jump
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure jump2
for i : 1 .. 15
y := y + 15
x := x + 9
cls
Pic.Draw (background, 1, 1, picXor)
Pic.Draw (jump1, x, y, picMerge)
View.Update
end for
for i : 1 .. 15
y := y - 15
x := x + 10
cls
Pic.Draw (background, 1, 1, picXor)
Pic.Draw (jump1, x, y, picMerge)
View.Update
end for
end jump2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure jump3
for i : 1 .. 15
y := y + 15
x := x - 9
cls
Pic.Draw (background, 1, 1, picXor)
Pic.Draw (jump1, x, y, picMerge)
View.Update
end for
for i : 1 .. 15
y := y - 15
x := x - 10
cls
Pic.Draw (background, 1, 1, picXor)
Pic.Draw (jump1, x, y, picMerge)
View.Update
end for
end jump3

loop
Pic.Draw (jump1, x, y, picMerge)
Input.KeyDown (keys)
if keys (KEY_UP_ARROW) then
jump
end if
if keys (KEY_RIGHT_ARROW) then
delay (100)
walkRight
delay(50)
Pic.Draw (man5, x, y, picMerge)
end if
if keys (KEY_LEFT_ARROW) then
delay (100)
for i : 1 .. 2
x := x - 70
cls
Pic.Draw (background, 1, 1, picXor)
Pic.Draw (man4, x, y, picMerge)
View.Update
end for
delay (50)
Pic.Draw (man5, x, y, picMerge)
end if
if keys (KEY_LEFT_ARROW) and x > 0 then
x := x + 1
end if
cls
Pic.Draw (background, 1, 1, picXor)
Pic.Draw (man5, x, y, picMerge)
if keys ('1') then
cls
Pic.Draw (background, 1, 1, picXor)
Pic.Draw (hit1, x, y, picMerge)
end if
if keys ('e') then
jump2
end if
if keys ('q') then
jump3
end if
if keys ('2') then
cls
Pic.Draw (background, 1, 1, picXor)
Pic.Draw (punch, x, y, picMerge)
end if
if keys ('3') then
cls
Pic.Draw (background, 1, 1, picXor)
Pic.Draw (kick, x, y, picMerge)
end if
if keys (KEY_DOWN_ARROW) then
cls
Pic.Draw (background, 1, 1, picXor)
Pic.Draw (duck, x, y, picMerge)
end if
View.Update
end loop
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ProgrammingFun




PostPosted: Tue Jun 07, 2011 8:21 pm   Post subject: RE:making boundries

It always helps to indent and to use the [syntax="turing"] [/syntax] tags.

EDIT: It has been mentioned already as well...
crossley7




PostPosted: Tue Jun 07, 2011 8:42 pm   Post subject: RE:making boundries

That code is a nightmare to try to look at to help you out. If you want productive help, try doing as mentioned above. If it is like that in your turing screen, pressing F2 always helps for reading code easily.
roosterfest123




PostPosted: Tue Jun 07, 2011 8:50 pm   Post subject: Re: making boundries

Turing:
put "View.Set ("offscreenonly")
setscreen ("
graphics:max;678;nobuttonbar")
var punch, jump1, kick, man2, man3, man4, duck, hit1 : int
var man5 : int
var background : int
var count : boolean
var keys : array char of boolean
var x := 1
var y := 1
background := Pic.FileNew ("
background.bmp")
jump1 := Pic.FileNew ("
jump.bmp")
man2 := Pic.FileNew ("
man2.bmp")
duck := Pic.FileNew ("
duck.bmp")
man3 := Pic.FileNew ("
man3.bmp")
kick := Pic.FileNew ("
kick.bmp")
man4 := Pic.FileNew ("
man4.bmp")
man5 := Pic.FileNew ("
man 5.bmp")
hit1 := Pic.FileNew ("
hit1.bmp")
punch := Pic.FileNew ("
punch.bmp")
procedure walkRight
    for i : 1 .. 2
        x := x + 70
        cls
        Pic.Draw (background, 1, 1, picXor)
        Pic.Draw (man4, x, y, picMerge)
        View.Update
    end for
end walkRight
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure jump
    for i : 1 .. 15
        y := y + 15
        cls
        Pic.Draw (background, 1, 1, picXor)
        Pic.Draw (jump1, x, y, picMerge)
        View.Update
    end for
    for i : 1 .. 15
        y := y - 15
        cls
        Pic.Draw (background, 1, 1, picXor)
        Pic.Draw (jump1, x, y, picMerge)
        View.Update
    end for
end jump
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure jump2
    for i : 1 .. 15
        y := y + 15
        x := x + 9
        cls
        Pic.Draw (background, 1, 1, picXor)
        Pic.Draw (jump1, x, y, picMerge)
        View.Update
    end for
    for i : 1 .. 15
        y := y - 15
        x := x + 10
        cls
        Pic.Draw (background, 1, 1, picXor)
        Pic.Draw (jump1, x, y, picMerge)
        View.Update
    end for
end jump2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure jump3
    for i : 1 .. 15
        y := y + 15
        x := x - 9
        cls
        Pic.Draw (background, 1, 1, picXor)
        Pic.Draw (jump1, x, y, picMerge)
        View.Update
    end for
    for i : 1 .. 15
        y := y - 15
        x := x - 10
        cls
        Pic.Draw (background, 1, 1, picXor)
        Pic.Draw (jump1, x, y, picMerge)
        View.Update
    end for
end jump3

loop
    Pic.Draw (jump1, x, y, picMerge)
    Input.KeyDown (keys)
    if keys (KEY_UP_ARROW) then
        jump
    end if
    if keys (KEY_RIGHT_ARROW) then
        delay (100)
        walkRight
        delay (50)
        Pic.Draw (man5, x, y, picMerge)
    end if
    if keys (KEY_LEFT_ARROW) then
        delay (100)
        for i : 1 .. 2
            x := x - 70
            cls
            Pic.Draw (background, 1, 1, picXor)
            Pic.Draw (man4, x, y, picMerge)
            View.Update
        end for
        delay (50)
        Pic.Draw (man5, x, y, picMerge)
    end if
    if keys (KEY_LEFT_ARROW) and x > 0 then
        x := x + 1
    end if
    cls
    Pic.Draw (background, 1, 1, picXor)
    Pic.Draw (man5, x, y, picMerge)
    if keys ('1') then
        cls
        Pic.Draw (background, 1, 1, picXor)
        Pic.Draw (hit1, x, y, picMerge)
    end if
    if keys ('e') then
        jump2
    end if
    if keys ('q') then
        jump3
    end if
    if keys ('2') then
        cls
        Pic.Draw (background, 1, 1, picXor)
        Pic.Draw (punch, x, y, picMerge)
    end if
    if keys ('3') then
        cls
        Pic.Draw (background, 1, 1, picXor)
        Pic.Draw (kick, x, y, picMerge)
    end if
    if keys (KEY_DOWN_ARROW) then
        cls
        Pic.Draw (background, 1, 1, picXor)
        Pic.Draw (duck, x, y, picMerge)
    end if
    View.Update
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  [ 17 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: