Computer Science Canada Projectile game help |
Author: | Murthtwo [ Wed Dec 12, 2007 11:06 am ] |
Post subject: | Projectile game help |
Can somebody help me create a game were the user has to hit a randomly placed target and the user must be able to choose were they shoot from by clicking the mouse, as well as being able to choose how hard they want to shoot the ball . If the user clicks in a space they are not aloud to shoot from, it cant let them, and it has to keep track of their score. If you have any tips or even the whole code, please help me ![]() |
Author: | HeavenAgain [ Wed Dec 12, 2007 11:15 am ] |
Post subject: | RE:Projectile game help |
this is just physics, the easiest way to do this, is just let user enters the initial speed and angle, slap me if im wrong but i think the equation is this x2 = x1 + V*cos(theta)*t y2 = y1 + V*sin(theta)*t - (1/2)*g*t^2 and just draw the x and y of this dot or circle or w/e and what if we have the whole code? ![]() |
Author: | petree08 [ Wed Dec 12, 2007 1:13 pm ] |
Post subject: | RE:Projectile game help |
Wait, are you having a turret type game, if so you'll need to find angles between the turret and the mouse co-ordinates before you can implement the previously stated physics. this can be acomplished using turing's trig functions such as acrtand - tan inverse in degrees acrsind -sin inverse in degrees arccosd - cos inverse in degrees theses commands also work in radians just drop the d at the end. look at the turing help for trig for a fuller explanAtion - happy coding |
Author: | Murthtwo [ Wed Dec 12, 2007 1:31 pm ] |
Post subject: | Re: Projectile game help |
Thank you soo much, at least now i can tackle this thing with some knowledge : |
Author: | Murthtwo [ Thu Dec 13, 2007 10:47 am ] |
Post subject: | Re: Projectile game help |
I need help with what I have so far, can anybody tell me how to fix when i shoot the ball; the target and the line disapear after you click and if you click above the line its supposed to say "->Please try again<-" and it does but its too fast for anyone to see :'( "->Invalid Position<-" setscreen ("graphics:max;max") var font1, font2, font3 : int var ovalx, ovaly : int var start : int var load : string := "Loading" var displacement : int var force : int var launchx, launchy : int var buttonnumber, buttonupdown : int var zz : int := 1 var rad, rad2 : int rad := 10 rad2 := 25 launchx := maxx div 2 launchy := maxy div 2 ovalx := Rand.Int (1, 619) ovaly := Rand.Int (150, 399) font1 := Font.New ("Stenvil:40") Font.Draw ("Welcome to Johnathon's Target Game",100,600, font1, 1) Font.Free (font1) font1 := Font.New ("Stencil:40") Font.Draw ("1. Objective/Controls", 530, 394, font1, 1) Font.Free (font1) font2 := Font.New ("Stencil:40") Font.Draw ("2. Comence Game", 530, 324, font2, 1) Font.Free (font2) get start if start = 1 then cls font3 := Font.New ("Stencil:40") Font.Draw ("Objective/Controls", 613, 624, font3, 53) Font.Free (font3) drawbox (461, 407, 1032, 499, black) color (53) locate (20, 60) put " Click somewhere under the line to launch the ball from the cannon " .. locate (21, 60) put " The objective is to hit the target with the ball" .. locate (22, 60) put " Each time you hit the target, you recieve 10 points" .. locate (23, 60) put " If you miss the target, you loose 20 points" .. Input.Pause cls end if if start = 2 then cls end if proc target drawfilloval (ovalx, ovaly, rad2, rad2, brightred) drawfilloval (ovalx, ovaly, 15, 15, white) drawfilloval (ovalx, ovaly, 8, 8, brightred) end target proc ball for i : 1 .. 1000 by 2 displacement := round (1 / 250 * (- (i - 40 * force) ** 2 + (40 * force) ** 2)) drawfilloval (launchx + i, launchy + displacement, rad, rad, blue) View.Update cls end for end ball color (53) locate (20, 60) put " How hard do you want to shoot your ball?" delay (100) locate (21, 75) put " 1-2-3-4-5-6-7-8 " locate (25, 70) put "Force = " .. 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 end if colorback (grey) cls Draw.ThickLine (1, 150, 2000, 150, 5, black) target loop setscreen ("offscreenonly") Draw.ThickLine (1, 150, 2000, 150, 5, black) 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) target else locate (20, 60) put " ->Please try again<- " locate (21, 60) put " ->Invalid Position<-" end if View.Update cls end loop |
Author: | HeavenAgain [ Thu Dec 13, 2007 11:34 am ] |
Post subject: | RE:Projectile game help |
what the hell is this? what classmates? comparing with the codes, there are A LOT of similarities.... |
Author: | Murthtwo [ Thu Dec 13, 2007 11:45 am ] |
Post subject: | Re: Projectile game help |
People saw what i posted and copied me :'( But please, i need help with this. |
Author: | Dan [ Thu Dec 13, 2007 1:23 pm ] |
Post subject: | Re: Projectile game help |
Murthtwo @ 13th December 2007, 11:45 am wrote: People saw what i posted and copied me :'(
But please, i need help with this. I hate it when peoleop travel into the future copy me, and then go back to there time and post it. We deftaly need to get some laws about code copyers using time mashens. For the fools who do not get it check the post time of his post and the one he side copyed him. |
Author: | agnivohneb [ Thu Dec 13, 2007 3:14 pm ] |
Post subject: | RE:Projectile game help |
I noticed this too. The code in the other post is gone and who is OP. |
Author: | Clayton [ Thu Dec 13, 2007 3:18 pm ] |
Post subject: | RE:Projectile game help |
OP = Original Poster. The code is in a better place now. |
Author: | petree08 [ Mon Dec 17, 2007 11:04 am ] |
Post subject: | RE:Projectile game help |
U'm there are some huge flaws in your coding conventions. I noticed the if structure where you get the force from the user if Force =1 then Force := 1 end if This is completely redundent. Also .. proc ball for i : 1 .. 1000 by 2 displacement := round (1 / 250 * (- (i - 40 * force) ** 2 + (40 * force) ** 2)) drawfilloval (launchx + i, launchy + displacement, rad, rad, blue) View.Update cls end for end ball I don't understand why you are using a for when animating something cuz it stops you from having two things at once moving.. this is why your drawline just pops up afterwords. also i don't get your implementaion of the mouse. And to those copying this. This is a begginers attempt at a game it's a good start but has huge flaws, if your going to bother copying copy from a good source and try to understand the code. any way that was my rant keep trying man |
Author: | Nick [ Mon Dec 17, 2007 11:33 am ] |
Post subject: | Re: RE:Projectile game help |
petree08 @ Mon Dec 17, 2007 11:04 am wrote: ...And to those copying this. This is a begginers attempt at a game it's a good start but has huge flaws, if your going to bother copying copy from a good source and try to understand the code.
...keep trying man dude you completely missed who copied it... Murthtwo copied this from Gergysun (that guy who asked a lot of questions but did his own work) |
Author: | agnivohneb [ Mon Dec 17, 2007 12:42 pm ] |
Post subject: | RE:Projectile game help |
you might want to read the fine print in dans post |
Author: | petree08 [ Mon Dec 17, 2007 8:28 pm ] |
Post subject: | RE:Projectile game help |
lol sorry but still there are a lot of people copying bad code. |
Author: | gergysun [ Mon Dec 17, 2007 9:09 pm ] |
Post subject: | Re: Projectile game help |
LOL, i know how i wrote the code... i know that the if force = whatver is completely not needed but still. Second.. i used the proc ball and the displacement stuff cause..well...umm..we have to ..Its for a class. This was one of the *manditory* tihngs we had to do. **Excluding the proc** i just used the proc to make it shorter in the long run. |
Author: | syntax_error [ Mon Dec 17, 2007 11:26 pm ] |
Post subject: | Re: Projectile game help |
not really important but an idea don't always free the font right after you use it free is in the end so you don't have many of the same fonts being held in different vars Murthtwo wrote: If you have any tips or even the whole code, please help me Very Happy err just a thought before posting try reading the rules |