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

Username:   Password: 
 RegisterRegister   
 Can someone help me with my 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 5:56 pm   Post subject: Can someone help me with my project?

I made a target game which the user has to try to hit the target with the ball. How can I make the game track points for the user. Every time the user hits the target they are suppost to get 20 points.
This is what I have so far:
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 := 10
rady := 25
%Score numbers
var score : int := 0
var score2 : int := 20

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

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



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

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



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

font1 := Font.New ("Algerian:50")
Font.Draw ("1.Instructions", 400, 390, font1, brightblue)
Font.Free (font1)

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


get start

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

color (brightblue)
locate (20, 30)
put "Click somewhere under the black line to launch the ball from the cannon" ..
locate (21, 30)
put "All you have to do is try to hit the target"
locate (22, 30)
put "Every time you hit the target you will get 20 points"
locate (23, 30)
put "You will lose 20 points for everytime you miss the target"
locate (24, 30)
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, 7, 7, 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, 7, 7, brightred)
Draw.ThickLine (1, 152, 1900, 152, 8, black)
setscreen ("offscreenonly")
Draw.ThickLine (1, 152, 1900, 152, 8, black)


View.Update
cls

end for
end ball

%Force of the ball
color (black)
drawfill(10,10,red,black)
locate (20, 60)
put "What force do you want a use?"
delay (100)
locate (21, 60)
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
locate (5, 5)
put "Score:", score



%Thickline
Draw.ThickLine (1, 152, 1900, 152, 8, 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, 152, 1900, 152, 8, black)
ovalx := Rand.Int (1, 615)
ovaly := Rand.Int (150, 390)
cls
else
target

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








end if

end loop
Sponsor
Sponsor
Sponsor
sponsor
syntax_error




PostPosted: Mon Dec 24, 2007 6:08 pm   Post subject: Re: Can someone help me with my project?

well i havent read your code but a quick solution would be
to simply check when the target is hit
then make another var set it to zero first then add 20 each time the target is hit but the user
seems simple enough

oo next time use code tags makes life easy on all of us Idea
Zampano




PostPosted: Mon Dec 24, 2007 9:54 pm   Post subject: Re: Can someone help me with my project?

I didn't look through all your code either, but this is pretty confusing.
code:
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
Dan




PostPosted: Mon Dec 24, 2007 10:03 pm   Post subject: RE:Can someone help me with my project?

I am locking this topic as it is an ininteal double post and the code is reportely stolen.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
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  [ 4 Posts ]
Jump to:   


Style:  
Search: