
-----------------------------------
roosterfest123
Tue Jun 07, 2011 3:40 pm

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?

-----------------------------------
Raknarg
Tue Jun 07, 2011 3:46 pm

RE:making boundries
-----------------------------------

if key (KEY_LEFT_ARROW) and x > 0 then
     x := x - 1
end if


-----------------------------------
roosterfest123
Tue Jun 07, 2011 3:53 pm

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
Tue Jun 07, 2011 5:48 pm

RE:making boundries
-----------------------------------
Could you attach the pictures?

So why do you use a procedure for walking left and right?

-----------------------------------
Tony
Tue Jun 07, 2011 5:51 pm

Re: RE:making boundries
-----------------------------------

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 


-----------------------------------
Raknarg
Tue Jun 07, 2011 6:03 pm

RE:making boundries
-----------------------------------
good call, didn't see that. It's going left twice.

-----------------------------------
apython1992
Tue Jun 07, 2011 6:55 pm

RE:making boundries
-----------------------------------
Also, if I may pop in here - use syntax tags in the future.

put "Welcome!"put "Welcome!"

-----------------------------------
Raknarg
Tue Jun 07, 2011 7:03 pm

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.

-----------------------------------
Raknarg
Tue Jun 07, 2011 7:04 pm

RE:making boundries
-----------------------------------
The walk left and right ones, I mean.

-----------------------------------
roosterfest123
Tue Jun 07, 2011 7:49 pm

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
Tue Jun 07, 2011 8:01 pm

RE:making boundries
-----------------------------------
Can you post your update code using the syntax tags I showed you?

-----------------------------------
roosterfest123
Tue Jun 07, 2011 8:03 pm

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
Tue Jun 07, 2011 8:21 pm

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
Tue Jun 07, 2011 8:42 pm

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
Tue Jun 07, 2011 8:50 pm

Re: making boundries
-----------------------------------
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"

-----------------------------------
Tony
Tue Jun 07, 2011 8:51 pm

RE:making boundries
-----------------------------------
Not only that, but there's also a lot of code that's irrelevant to the problem. If you cut it down to the minimum example that demonstrates the problem, it will have _two_ good effects:

- it will be easier for you to figure out exactly what's going on
- it will be _much_ easier for others to read your code, and thus be more likely to help you.

-----------------------------------
apython1992
Tue Jun 07, 2011 8:53 pm

RE:making boundries
-----------------------------------
Put all of your code between the tags.


put "I"
put "am"
put "writing"
put "many"
put "lines"
put "of"
put "code"

put "I"
put "am"
put "writing"
put "many"
put "lines"
put "of"
put "code"

