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

Username:   Password: 
 RegisterRegister   
 Shooter help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
WooFerPPK




PostPosted: Wed Oct 16, 2002 1:08 am   Post subject: Shooter help

im making a program that shoots a > sign to a @ sign, my problem is when > goes past @ it doesnt show. here is my code.
i acidently put Y as column and X as row
please help

BTW, this code is long.

code:

% This program i will shoot a > at a @ sign
% *Note* Y is column and X is row
colorback (black)
color (10)
cls

loop
    cls
    % The vars
    var x, y : int
    var x2, y2 : int
    var single : string

    % This will ask the user if he wants to play single player or not
    put "Would you like to play single player"
    get single

    % if he says no then it will jump to 2 players and user1 will have to type
    % the coordients
    if single = "no" then
        loop
            put "Please enter the cordents for X, and Y"
            put "x : X must equal anyware from 1 to 25"
            get x
            cls
            exit when x <= 25
        end loop

        loop
            put "Please enter the cordents for X, and Y"
            put "y : Y must equal anyware from 1 to 80"
            get y
            cls
            exit when y <= 80
        end loop

        % if user says yes then it will make it 1 player and while randomly
        % place the @ sign
    elsif single = "yes" then
        x := Rand.Int (3, 24)
        y := Rand.Int (3, 75)

        % my testing code
    elsif single = "debug" then
        x := Rand.Int (3, 24)
        y := Rand.Int (3, 75)

        put x
        put y
    end if

    % puts @ on the screen
    locate (x, y)
    put "@"

    % X is the row
loop
        locate (1, 1)
        put "Guess what cordinates the @ sign is located at"
        put "x : X must equal anyware from 1 to 25"
        get x2
        cls


        % Y is column
        put "y : Y must equal anyware from 1 to 80"
        locate (x, y)
        put "@"
        locate (2, 1)
        get y2

        exit when x2 <= 25 and y2 <= 80
        locate (10, 35)
        put "Somthing you inputted is incorrect, try again"
        delay (2000)
    end loop
    cls

% keeps @ on screen
    locate (x, y)
    put "@"

% the shooter
    for shoot : 1 .. y2
        locate (x2, shoot)
        delay (100)
        put ">"

        locate (x, y)
        put "@"
    end for

% Hit or Miss.
    if x2 = x and y2 = y then
        locate (15, 35)
        put "You hit the target!"
    elsif x2 <= x and y2 <= x then
        locate (15, 35)
        put "You missed"
    elsif x2 >= x and y2 >= x then
        locate (15, 35)
        put "You missed"
    end if

% ask user if he wants to play again.
    var question : string
    locate (1, 1)
    put "Do you want to play again?"
    locate (2, 1)
    get question
    exit when question = "no" or question = "No"
end loop
cls
Sponsor
Sponsor
Sponsor
sponsor
WooFerPPK




PostPosted: Fri Oct 18, 2002 7:56 am   Post subject: (No subject)

some help please?

i think this is the problem here

code:
% the shooter
    for shoot : 1 .. y2
        locate (x2, shoot)
        delay (100)
        put ">"

        locate (x, y)
        put "@"
    end for


i dont know what to do to get > passed @ when it needs to
Tony




PostPosted: Sat Oct 19, 2002 9:56 am   Post subject: (No subject)

Hmm... It might have something to do with compiler.

I think that in older versions, the locate is buggy and will erase the rest of the line after the text that was on it.

And since the put "@" is after put ">" it might erace the > that you already put after the @ sign.

Try getting a newer version of compiler or write your own function inctead of locate()
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Mike Pastah




PostPosted: Fri Nov 08, 2002 4:57 am   Post subject: (No subject)

lol, i have no idea what's wrong, but that's a cool game.. simple, yet... cool Very Happy
WooFerPPK




PostPosted: Fri Nov 08, 2002 5:42 am   Post subject: (No subject)

lol, thanks it took me a while to fiqure that out, btw thats a program u might do to if ur learning the same thing i am.
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 1  [ 5 Posts ]
Jump to:   


Style:  
Search: