
-----------------------------------
horlickiki
Fri Mar 18, 2005 7:12 pm

Exiting this loop...
-----------------------------------



setscreen ("graphics:640;400")
var y : int %%%%%%%%%%%%%%%%%%% temp?

%VARIABLE DECLARATION / ARRAY DECLARATION

var fonta := Font.New ("Amerigo BT:36")
var fontb := Font.New ("Amerigo BT:24")
var fontc := Font.New ("Amerigo BT:18")
var fontd := Font.New ("Amerigo BT:14")
var fontcountdown := Font.New ("Amerigo BT:144")

var ctc : string (1)
var movex : string (1)

var mmptxchoice : int
var modechoiceptx : int
var countdown : int := 3
var move : int := 305

var mmptxoption : flexible array 1 .. 3 of string
var modeptx : flexible array 1 .. 3 of string

mmptxoption (1) := "1. Play"
mmptxoption (2) := "2. View Instructions"
mmptxoption (3) := "3. Exit"
modeptx (1) := "1. 1 Player"
modeptx (2) := "2. 2 Players"
modeptx (3) := "3. Exit"

% PROCEDURE DECLARATION / PROCESS DECLARATION

proc X
    Font.Draw ("Nobody Is Winning", 220, 100, fontc, 0)
    loop
        Font.Draw ("X", move, 200, fontb, 0)
        drawline (315, 180, 315, 240, 0)
        %drawline (0, 210, 305, 210, 0)
        %drawline (335, 210, 640, 210, 0)
        if hasch then
            getch (movex)
            if movex = "S" or movex = "s" then
                move -= 10
                Font.Draw ("X", move + 10, 200, fontb, 7)
            elsif movex = "J" or movex = "j" then
                move += 10
                Font.Draw ("X", move - 10, 200, fontb, 7)
            end if
            cls
            if move < 305 then
                Font.Draw ("Player 1 Is Winning", 220, 100, fontc, 0)
            elsif move > 305 then
                Font.Draw ("Player 2 Is Winning", 220, 100, fontc, 0)
            else
                Font.Draw ("Nobody Is Winning", 220, 100, fontc, 0)
                exit when move = 0 or move = maxx
            end if
        end if

    end loop
end X
proc player1ptx
    cls
    Font.Draw ("Get Ready...", 220, 300, fontb, 0)
    Font.Draw ("Press Any Key To Start The Countdown", 150, 100, fontd, 0)
    locatexy (310, 50)
    getch (ctc)
    cls
    for q : 1 .. 3
        Font.Draw (intstr (countdown), 250, 150, fontcountdown, 0)
        %locatexy (310, 50)
        %put countdown
        countdown := countdown - 1
        delay (1000)
        cls
    end for
    Font.Draw ("Go!!!", 120, 120, fontcountdown, 0)
    delay (1000)
    cls
    X
end player1ptx

proc rtmm
    cls
    Font.Draw ("That Was Not An Option:", 85, 300, fontb, 0)
    Font.Draw ("Redirecting To main menu", 85, 200, fontb, 0)
    delay (600)
    Font.Draw (".", 460, 200, fontb, 0)
    delay (600)
    Font.Draw (".", 470, 200, fontb, 0)
    delay (600)
    Font.Draw (".", 480, 200, fontb, 0)
    delay (600)
end rtmm

%WELCOME MENU
color (0)
colorback (black)
cls
Font.Draw ("Welcome To Pull The X", 60, 300, fonta, 0)
delay (1000)
Font.Draw ("Press Any Key To Continue...", 200, 30, fontd, 0)
locatexy (470, 40)
getch (ctc)


%MAIN MENU
%loop
loop
    colorback (7)
    cls
    Font.Draw ("Choose An Option From The List:", 85, 300, fontb, 0)
    y := 220
    for menuptx : 1 .. 3
        y := y - 50
        Font.Draw (mmptxoption (menuptx), 100, y, fontd, 0)
    end for
    locatexy (400, 120)
    get mmptxchoice
    %%%%%%%%%%%%%%%%% OPTION 1 %%%%%%%%%%%%%%%%%%
    if mmptxchoice = 1 then
        cls
        Font.Draw ("Choose Mode", 100, 300, fontb, 0)
        y := 220
        for playptx : 1 .. 3
            y := y - 50
            Font.Draw (modeptx (playptx), 100, y, fontd, 0)
        end for
        locatexy (400, 120)
        get modechoiceptx
        if modechoiceptx = 1 then
            player1ptx
        end if
        %%%%%%%%%%%%%%%%% OPTION 2 %%%%%%%%%%%%%%%%
    elsif mmptxchoice = 2 then
        cls
        Font.Draw ("Instructions:", 220, 300, fontb, 0)
        Font.Draw ("Tap Your Key Until The X Has Reached Your Side Of The Screen", 50, 180, fontd, 0)
        Font.Draw ("Player 1 Controls:", 40, 120, fontc, 0)
        Font.Draw ("S Key Moves The X To The Left", 20, 80, fontd, 0)
        Font.Draw ("Player 2 Controls:", 360, 120, fontc, 0)
        Font.Draw ("J Key Moves The X To The Right", 340, 80, fontd, 0)
        Font.Draw ("Press Any Key To Continue...", 170, 10, fontd, 0)
        locatexy (430, 10)
        getch (ctc)
        %%%%%%%%%%%%%%%%%% OPTION 3 %%%%%%%%%%%%%%%%%%%%%%%
    elsif mmptxchoice = 3 then
        exit
    else
        rtmm
    end if
end loop


why doesnt't proc X end?

-----------------------------------
Bacchus
Fri Mar 18, 2005 9:07 pm


-----------------------------------
caus e its in a loop and there no exit or exit when in it, so it just keeps going lol

-----------------------------------
mike200015
Fri Mar 18, 2005 11:27 pm


-----------------------------------
there is an exit when exit when move = 0 or move = maxx

-----------------------------------
Bacchus
Fri Mar 18, 2005 11:43 pm


-----------------------------------
oops didnt see that lol kinda hidden there :P try
exit when move = maxx cause 305 being -10 wwont give you 0 same for maxx (but u can set to a 5 if u want)

-----------------------------------
ssr
Sat Mar 19, 2005 1:05 pm


-----------------------------------
actually that wont fully work yet
U PUT IT IN THE WRONG LOOP!!
the exit when will only exit teh if statement not teh whole loop
just move it to right before end loop
try it 

setscreen ("graphics:640;400") 
var y : int %%%%%%%%%%%%%%%%%%% temp? 

%VARIABLE DECLARATION / ARRAY DECLARATION 

var fonta := Font.New ("Amerigo BT:36") 
var fontb := Font.New ("Amerigo BT:24") 
var fontc := Font.New ("Amerigo BT:18") 
var fontd := Font.New ("Amerigo BT:14") 
var fontcountdown := Font.New ("Amerigo BT:144") 

var ctc : string (1) 
var movex : string (1) 

var mmptxchoice : int 
var modechoiceptx : int 
var countdown : int := 3 
var move : int := 305 

var mmptxoption : flexible array 1 .. 3 of string 
var modeptx : flexible array 1 .. 3 of string 

mmptxoption (1) := "1. Play" 
mmptxoption (2) := "2. View Instructions" 
mmptxoption (3) := "3. Exit" 
modeptx (1) := "1. 1 Player" 
modeptx (2) := "2. 2 Players" 
modeptx (3) := "3. Exit" 

% PROCEDURE DECLARATION / PROCESS DECLARATION 

proc X 
Font.Draw ("Nobody Is Winning", 220, 100, fontc, 0) 
loop 
Font.Draw ("X", move, 200, fontb, 0) 
drawline (315, 180, 315, 240, 0) 
%drawline (0, 210, 305, 210, 0) 
%drawline (335, 210, 640, 210, 0) 
if hasch then 
getch (movex) 
if movex = "S" or movex = "s" then 
move -= 10 
Font.Draw ("X", move + 10, 200, fontb, 7) 
elsif movex = "J" or movex = "j" then 
move += 10 
Font.Draw ("X", move - 10, 200, fontb, 7) 
end if 
cls 
if move < 305 then 
Font.Draw ("Player 1 Is Winning", 220, 100, fontc, 0) 
elsif move > 305 then 
Font.Draw ("Player 2 Is Winning", 220, 100, fontc, 0) 
else 
Font.Draw ("Nobody Is Winning", 220, 100, fontc, 0) 
end if 
end if 
exit when move = maxx 
end loop 
end X 
proc player1ptx 
cls 
Font.Draw ("Get Ready...", 220, 300, fontb, 0) 
Font.Draw ("Press Any Key To Start The Countdown", 150, 100, fontd, 0) 
locatexy (310, 50) 
getch (ctc) 
cls 
for q : 1 .. 3 
Font.Draw (intstr (countdown), 250, 150, fontcountdown, 0) 
%locatexy (310, 50) 
%put countdown 
countdown := countdown - 1 
delay (1000) 
cls 
end for 
Font.Draw ("Go!!!", 120, 120, fontcountdown, 0) 
delay (1000) 
cls 
X 
end player1ptx 

proc rtmm 
cls 
Font.Draw ("That Was Not An Option:", 85, 300, fontb, 0) 
Font.Draw ("Redirecting To main menu", 85, 200, fontb, 0) 
delay (600) 
Font.Draw (".", 460, 200, fontb, 0) 
delay (600) 
Font.Draw (".", 470, 200, fontb, 0) 
delay (600) 
Font.Draw (".", 480, 200, fontb, 0) 
delay (600) 
end rtmm 

%WELCOME MENU 
color (0) 
colorback (black) 
cls 
Font.Draw ("Welcome To Pull The X", 60, 300, fonta, 0) 
delay (1000) 
Font.Draw ("Press Any Key To Continue...", 200, 30, fontd, 0) 
locatexy (470, 40) 
getch (ctc) 


%MAIN MENU 
%loop 
loop 
colorback (7) 
cls 
Font.Draw ("Choose An Option From The List:", 85, 300, fontb, 0) 
y := 220 
for menuptx : 1 .. 3 
y := y - 50 
Font.Draw (mmptxoption (menuptx), 100, y, fontd, 0) 
end for 
locatexy (400, 120) 
get mmptxchoice 
%%%%%%%%%%%%%%%%% OPTION 1 %%%%%%%%%%%%%%%%%% 
if mmptxchoice = 1 then 
cls 
Font.Draw ("Choose Mode", 100, 300, fontb, 0) 
y := 220 
for playptx : 1 .. 3 
y := y - 50 
Font.Draw (modeptx (playptx), 100, y, fontd, 0) 
end for 
locatexy (400, 120) 
get modechoiceptx 
if modechoiceptx = 1 then 
player1ptx 
end if 
%%%%%%%%%%%%%%%%% OPTION 2 %%%%%%%%%%%%%%%% 
elsif mmptxchoice = 2 then 
cls 
Font.Draw ("Instructions:", 220, 300, fontb, 0) 
Font.Draw ("Tap Your Key Until The X Has Reached Your Side Of The Screen", 50, 180, fontd, 0) 
Font.Draw ("Player 1 Controls:", 40, 120, fontc, 0) 
Font.Draw ("S Key Moves The X To The Left", 20, 80, fontd, 0) 
Font.Draw ("Player 2 Controls:", 360, 120, fontc, 0) 
Font.Draw ("J Key Moves The X To The Right", 340, 80, fontd, 0) 
Font.Draw ("Press Any Key To Continue...", 170, 10, fontd, 0) 
locatexy (430, 10) 
getch (ctc) 
%%%%%%%%%%%%%%%%%% OPTION 3 %%%%%%%%%%%%%%%%%%%%%%% 
elsif mmptxchoice = 3 then 
exit 
else 
rtmm 
end if 
end loop 
  :D eh? hopefully it works
btw u want to shorten ur codes?

-----------------------------------
Bacchus
Sat Mar 19, 2005 3:57 pm


-----------------------------------
exit really only cause loops and for loops to exit, pretty sure it wouldnt matter if the exit is in an if cause i do it all the time

-----------------------------------
Cervantes
Sat Mar 19, 2005 6:16 pm


-----------------------------------
exit really only cause loops and for loops to exit, pretty sure it wouldnt matter if the exit is in an if cause i do it all the time
Bacchus is correct.  The reason your code works, ssr, is because you used the >= and 