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

Username:   Password: 
 RegisterRegister   
 mousewhere in a target shooting game
Index -> Programming, Turing -> Turing Help
Goto page Previous  1, 2, 3
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
nightfeng2




PostPosted: Fri Jan 14, 2011 9:25 am   Post subject: Re: mousewhere in a target shooting game

Turing:

%By: Nightfeng2
setscreen ("graphics:800;600,offscreenonly")
var targetx, targety, Mx, My, button, CC, score, bullets, timer, button2 : int
score := 0
bullets := 20
CC := 7 %crosshair color




    loop
        randint (targetx, 50, 750)     %%%targets x coor
        randint (targety, 50, 550)     %targets y coor
        loop

            put "Your score: ", score, " Bullets: ", bullets
            %%%%the target
            drawfilloval (targetx, targety, 50, 50, 12)
            drawfilloval (targetx, targety, 35, 35, 31)
            drawfilloval (targetx, targety, 20, 20, 12)
            drawfilloval (targetx, targety, 5, 5, 31)

            %%%crosshair
            mousewhere (Mx, My, button)
            drawoval (Mx, My, 100, 100, CC)
            drawline (Mx, My, Mx, My + 100, CC)
            drawline (Mx, My, Mx + 100, My, CC)
            drawline (Mx, My, Mx - 100, My, CC)
            drawline (Mx, My, Mx, My - 100, CC)
            drawoval (Mx, My, 50, 50, CC)
            drawfilloval (Mx, My, 3, 3, 4)
            View.Update
            cls

            if button = 1 then
                button2 := button

                exit
            end if


        end loop



        if Mx <= targetx + 50 and Mx >= targetx - 50 and My <= targety + 50 and My >= targety - 50 and button2 = 1 then     %if the cc hit the target, score+1
            score += 1
            bullets -= 1
        elsif button2 = 1 then
            bullets -= 1
            exit when bullets <= 0
        end if
        exit when bullets <= 0
    end loop
    put "Your final score is: ", score






this is what i can do right now, im sure u what you mean is different from me. giving an example of code would really help. thx
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Fri Jan 14, 2011 1:08 pm   Post subject: Re: mousewhere in a target shooting game

nightfeng2 @ Fri Jan 14, 2011 9:25 am wrote:

if button = 1 then
button2 := button

This part will guarantees that both button and button2 will always be the same when you exit the loop. Read your if statements out-loud to make sure they make sense to you: "if button is 1 then assign value of button (1) to button2".
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
nightfeng2




PostPosted: Fri Jan 14, 2011 7:15 pm   Post subject: RE:mousewhere in a target shooting game

i changed the game to timer system, its not bad actually, ill try the bullet system again after the assignment cuz its due very soon
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 3 of 3  [ 33 Posts ]
Goto page Previous  1, 2, 3
Jump to:   


Style:  
Search: