Posted: Fri Dec 02, 2011 7:39 pm Post subject: help with game?
What is it you are trying to achieve?
I want to make a fully functional shooting game with humans that pop up on the screen and you shoot them and the game calculates how many times you succesfully shoot them, what i really want out of this is how to get it so that when you have the circle on the human and press the spacebar it calculates one more point, this is the only thing i am having trouble with at the moment.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
Turing:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Author: Daniel ... % Date: November 29, 2011 % Filename: TuringGraphics.t % Description: graphics %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
endif Draw.FillBox(0, 450, 1200, 800, 79)%keeps updating the sky, and drawing sky Draw.FillBox(0, 0, 1200, 450, green)%keeps updating the grass, and drawing grass Draw.FillOval(x, y, 10, 10, red)%Draws oval View.Update endloop
Sponsor Sponsor
RandomLetters
Posted: Fri Dec 02, 2011 9:36 pm Post subject: RE:help with game?
What do you mean by "calculates one more point". What is the "point"? Where the bullet hits? The other corner of the crosshair?
programmer1337
Posted: Sat Dec 03, 2011 11:59 am Post subject: Re: help with game?
well what i mean is that with each hit on the human or whatever it will add one point to your total score, i would know how to calculate the score, but i need to know how to hit the humans so that when you press the spacebar and the dot is on them at the same time, it interprets it as a hit
RandomLetters
Posted: Sat Dec 03, 2011 3:20 pm Post subject: Re: help with game?
one way is to use whatdotcolor, which works if your targets are all the same color, and unique from the background. Before you draw the cursor, check the color of the new coordinate, and if it is the correct color, then you know it hit.
code:
var targetcolor : int
targetcolor := 1
Draw.FillBox (200, 100, 250, 150, targetcolor) %a target
if whatdotcolor(x, y) = targetcolor then
%Add score
end if
Draw.FillOval (x, y, 10, 10, red) %Draws oval
Just a guess, but delaying for 1/2 second after a random delay of 1/100th to 1/10th of a second is probably going to cause some "lag".
programmer1337
Posted: Sat Dec 03, 2011 3:49 pm Post subject: Re: help with game?
ok all i want to do is randomly make the ovals pop up and then with the mouse i click on them before they disappear, and that adds a point, so what should i do?
RandomLetters
Posted: Sat Dec 03, 2011 3:55 pm Post subject: RE:help with game?
You should have only one delay in your loop. This delay should be the one which sets the (max) length per frame.
To have targets pop out randomly, instead of another delay, use a counter to count the number of frames that have passed.
Sponsor Sponsor
programmer1337
Posted: Sat Dec 03, 2011 3:57 pm Post subject: Re: help with game?
can you please just start me off, with the counter?
RandomLetters
Posted: Sat Dec 03, 2011 7:48 pm Post subject: RE:help with game?
code:
var c : int
var duration: int
var frame: int
frame := 17 %60 fps
loop
c += 1 %counts the # of frames
if c * frame > duration then %multiplying the # of frames by the time per frame and check if that time is greater
duration := randomnumber(); %you can change the duration each time
c := 0
end if
delay(frame)
end loop
to make sure the duration doesnt change for slow computers, you can (in fact should) also use things like time.elapsed and time.delaysincelast instead of a counter and delay. However, the concept is still the same.
Maybe I'm editing too much
programmer1337
Posted: Sat Dec 03, 2011 9:30 pm Post subject: Re: help with game?
this is my current code and it isnt working what should i do?
code:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Author: Daniel ..
% Date: November 29, 2011
% Filename: TuringGraphics.t
% Description: graphics
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
View.Set ("graphics:1200;800,offscreenonly")
var count, count2, count1, x, y, rndInt, rndInt1, rndInt3 : int
var mx, my, mb : int %vars for the mouse where code
x := 400
y := 400
var c : int
var duration: int
var frame: int
frame := 17 %60 fps
rndInt := Rand.Int(100, 1000)
var chars : array char of boolean
loop
cls ()
Input.KeyDown (chars)
mousewhere (mx, my, mb)
if my > 790 then
my := 790
elsif my < 10 then
my := 10
end if
if mx > 1175 then
mx := 1175
elsif mx < 10 then
mx := 10
end if
Draw.FillBox (0, 450, 1200, 800, 79) %keeps updating the sky, and drawing sky
Draw.FillBox (0, 0, 1200, 450, green) %keeps updating the grass, and drawing grass
Draw.FillOval (mx, my, 5, 5, black) %Draws oval
if c * frame > duration then %multiplying the # of frames by the time per frame and check if that time is greater
duration := rndInt3 %you can change the duration each time
c := 0
end if
Draw.FillOval (rndInt, rndInt1, 40, 40, brightred)
Draw.FillOval (rndInt, rndInt1, 30, 30, white)
Draw.FillOval (rndInt, rndInt1, 10, 10, brightred)
delay(frame)
end loop
View.Update
end loop
Aange10
Posted: Sat Dec 03, 2011 9:52 pm Post subject: RE:help with game?
Problem #1 : Don't copy an paste somebody's code into your own. Why don't you try seeing what your telling the program to do, and see where you messed up?
EDIT: You need to remove
Turing:
Author: Daniel ..
Because you didn't write all of that code. Citations are necessary, or credit should be void. You can't just copy and paste something and call it yours.
programmer1337
Posted: Sat Dec 03, 2011 9:58 pm Post subject: Re: help with game?
dude i wouldnt copy it >.>, and maybe i forgot to take it out sorrryyyy, all i want is help not criticism
ProgrammingFun
Posted: Sat Dec 03, 2011 10:01 pm Post subject: Re: help with game?
programmer1337 @ Sat Dec 03, 2011 9:58 pm wrote:
dude i wouldnt copy it >.>, and maybe i forgot to take it out sorrryyyy, all i want is help not criticism
Copying won't help you...and helping you learn that is the best help you can ever get.
Understanding of coding does not come from copying (nor does anything else), it comes from understanding the code then implementing your own.
And what you have done by claiming authorship is commonly known as plagiarism and this is not a good thing in any industry, or life in general.
(and what do you mean by "i wouldnt copy it"? did someone forcefully make you do it?)
programmer1337
Posted: Sat Dec 03, 2011 10:06 pm Post subject: Re: help with game?
this is what i wanted, i copied his code into my own, then i wanted to make it so it worked, then when it works, i would tweak it and personalize it, then i would know how it works, because now it doesnt work, and im trying to understand it lol