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

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




PostPosted: Mon Dec 24, 2007 9:10 am   Post subject: Need help with project

Can someone tell me how can I make my target game track points for the user? The objective of the game is to try to hit the target with the ball. So how would I do that?
This is what I have so far:

[code]
code:
setscreen ("graphics:max;max")

%Font variables
var font1, font2, font3 : int

%Oval variables
var ovalx, ovaly : int

%Displacement variable
var displacement : int

%Start variable
var start : int

%Launchx and launchy variables
var launchx, launchy : int

%Force variable
var force : int

%button variables
var buttonnumber, buttonupdown : int

%Rad variables
var radx, rady : int

%Rad =
radx :=8
rady := 23

%Launchx and Launchy =
launchx := maxx div 2
launchy := maxy div 2

%ovals =
ovalx := Rand.Int (1, 615)
ovaly := Rand.Int (150, 390)

%Score numbers
var score : int := 0

%Score string values
var scores : string := ""
var playername : string

%Drawfill
drawfill (10, 10, yellow, black)

%Main screen
font1 := Font.New ("Bush ScriptMT:50")
Font.Draw ("This is the ball throwing game", 100, 600, font1, red)
Font.Free (font1)

font1 := Font.New ("Castellar:50")
Font.Draw ("1.Instructions", 530, 394, font1, brightblue)
Font.Free (font1)

font2 := Font.New ("Castellar:50")
Font.Draw ("2.Start the game", 520, 320, font2, brightblue)
Font.Free (font2)


get start

if start = 1 then
    cls
    drawfill (10, 10, brightblue, black)
    font3 := Font.New ("arial:50")
    Font.Draw ("Instructions", 610, 620, font3, brightred)
    Font.Free (font3)

    color (brightblue)
    locate (20, 60)
    put "Click somewhere under the black line to launch the ball from the cannon" ..
    locate (21, 60)
    put "All you have to do is try to hit the target"
    locate (22, 60)
    put "Every time you hit the target you will get 20 points"
    locate (23, 60)
    put "You will lose 20 points for everytime you miss the target"
    locate (24, 60)
    put "Hope you like my game and have fun"

    Input.Pause
    cls
end if

if start = 2 then
    cls
end if

%Target procedure
procedure target

    drawfilloval (ovalx, ovaly, rady, rady, brightred)
    drawfilloval (ovalx, ovaly, 14, 14, white)
    drawfilloval (ovalx, ovaly, 8, 8, brightred)

end target
%Procedure ball
procedure ball
    for i : 1 .. 1000 by 2
        displacement := round (1 / 250 * (- (i - 40 * force) ** 2 + (40 * force) ** 2))
        drawfilloval (launchx + i, launchy + displacement, radx, radx, blue)
        drawfilloval (ovalx, ovaly, rady, rady, brightred)
        drawfilloval (ovalx, ovaly, 14, 14, white)
        drawfilloval (ovalx, ovaly, 8, 8, brightred)
        Draw.ThickLine (1, 150, 2000, 150, 5, black)
        setscreen ("offscreenonly")
        Draw.ThickLine (1, 150, 2000, 150, 5, black)

        View.Update
        cls

    end for
end ball

%Force of the ball
color (black)
locate (20, 60)
put "What force do you want a use?"
delay (100)
locate (21, 75)
put "Choose a force from 1-10 and hit any key to continue"

get force
if force = 1 then
    force := 1
elsif force = 2 then
    force := 2
elsif force = 3 then
    force := 3
elsif force = 4 then
    force := 4
elsif force = 5 then
    force := 5
elsif force = 6 then
    force := 6
elsif force = 7 then
    force := 7
elsif force = 8 then
    force := 8
elsif force = 9 then
    force := 9
elsif force = 10 then
    force := 10
end if
colorback (white)
cls
loop
    %Thickline
    Draw.ThickLine (1, 150, 2000, 150, 5, black)
    %Buttonwait
    target

    View.Update
    buttonwait ("down", launchx, launchy, buttonnumber, buttonupdown)

    if launchx > 1 and launchx < 2000 and launchy < 150 and launchy > 10 then
        ball
        Draw.ThickLine (1, 150, 2000, 150, 5, black)
        ovalx := Rand.Int (1, 615)
        ovaly := Rand.Int (150, 390)
        cls


        target
          else
        locate (20, 60)
        put "Please click somewhere under the black line"
        delay (600)




    end if
end loop
[/code]
Sponsor
Sponsor
Sponsor
sponsor
Mazer




PostPosted: Mon Dec 24, 2007 9:38 am   Post subject: RE:Need help with project

I found some errors in your post. Corrections are in bold.

Joyeux No?l.
Saad




PostPosted: Mon Dec 24, 2007 10:04 am   Post subject: RE:Need help with project

Do people actually think that stolen code is not easy to find?, regardless of simple code changes?
I mean this code has been copied twice, but this person actually attempted to make it look not like the original.
TokenHerbz




PostPosted: Tue Jan 01, 2008 2:36 pm   Post subject: Re: Need help with project

Have a variable for your score. When ball hits target then add points to your score.
Tony




PostPosted: Tue Jan 01, 2008 5:59 pm   Post subject: RE:Need help with project

code:

if force = 1 then
    force := 1
elsif force = 2 then
    force := 2

Hahaha... what is this? Confused
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Clayton




PostPosted: Tue Jan 01, 2008 6:16 pm   Post subject: RE:Need help with project

It's a streamlining technique called redundancy.
Gooie




PostPosted: Wed Jan 02, 2008 2:41 am   Post subject: Re: RE:Need help with project

Tony @ January 1st, 5:59 pm wrote:
code:

if force = 1 then
    force := 1
elsif force = 2 then
    force := 2

Hahaha... what is this? Confused


I think its an attempt to avoid input errors.
Tony




PostPosted: Wed Jan 02, 2008 2:47 am   Post subject: RE:Need help with project

Gooie -- how would that avoid input errors?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: