Posted: Sat Dec 03, 2011 10:12 pm Post subject: RE:help with game?
I like the reasoning, but copying the code into yours program, and pasting the result here and asking us what's next isn't 'tweaking and personalizing' it.
If you need help you tell us the problem, what YOU'VE TRIED, and your results.
Saying 'It doesn't work what do i do', copying the code, and then saying it again doesn't do much good.
Sponsor Sponsor
RandomLetters
Posted: Sun Dec 04, 2011 12:58 am Post subject: RE:help with game?
Take a look at some of the simpler game programs that people have submitted in the submissions forum. They give you a good idea of how a typical game works.
programmer1337
Posted: Mon Dec 05, 2011 1:03 pm Post subject: Re: help with game?
this is my code now, but the problem is it just spams all of the targets im supposed to shoot at, at a rate no one can click it, how can i slow down the rate they pop-up without altering the mouse speed, or oval speed.
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)
c := 0
duration := 0
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)
View.Update
end loop
Aange10
Posted: Mon Dec 05, 2011 6:31 pm Post subject: Re: help with game?
Make a timer. Here's a basic timer.
(Btw, this is plenty of information to solve your problem. If not, this solves your problem for you, so don't ask me for help on 'wur do i pt it'.)
Posted: Mon Dec 05, 2011 6:54 pm Post subject: Re: help with game?
thank you very much, i wont bother you lol, just one last thingy im sorry but in this code
code:
if buttonmoved("down") and mousewhere(mx,my,mb) then
c := c + 1
end if
put c
it doesnt put c and it doesnt do anything lol
Aange10
Posted: Mon Dec 05, 2011 7:01 pm Post subject: RE:help with game?
If there are commands your not too familiar with, read the documentation. Obviously you are unfamiliar with mousewhere. The example in the documentation will show you its correct use, and fix your problem.
programmer1337
Posted: Mon Dec 05, 2011 7:14 pm Post subject: Re: help with game?
i tried doing this
code:
if buttonmoved("down") and my := rndInt1 and mx := rndInt then
c := c + 1
end if
put c
it still doesnt work?
Aange10
Posted: Mon Dec 05, 2011 7:38 pm Post subject: RE:help with game?
Read the error.
The things being compared have to be true or false. my := rndInt1 isn't true or false. my = rndInt1 is true or false
Sponsor Sponsor
programmer1337
Posted: Mon Dec 05, 2011 7:40 pm Post subject: Re: help with game?
yea that is what i put now sorry lol it works, i knew that my teacher told me sorry
programmer1337
Posted: Mon Dec 05, 2011 7:52 pm Post subject: Re: help with game?
Im sorry, I finished everything that i possibly could think of, one more thing all i want is to slow down the rates of which the target boards disappear instead of 1 millisecond to like 500 milliseconds
var count, count2, count1, x, y, rndInt, rndInt1, rndInt3 : int
var mx, my, mb : int %vars for the mouse where code
count2 := 0
x := 400
y := 400
var c : int
var duration : int
var frame : int
frame := 17 %60 fps
rndInt := Rand.Int (100, 1000)
c := 0
duration := 0
count1 := Time.Elapsed()
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, 2, 2, black) %Draws oval
put Time.Elapsed()
rndInt3 := Rand.Int (1000, 10000)
rndInt := Rand.Int (10, 1150)
rndInt1 := Rand.Int (10, 550)
if mb = 1 and mx = rndInt and my = rndInt1 then
c := c + 1
delay(200)
end if
put "Score: "..
put c
Posted: Mon Dec 05, 2011 8:04 pm Post subject: RE:help with game?
The attachment above shows you how to make a timer.
programmer1337
Posted: Mon Dec 05, 2011 8:10 pm Post subject: Re: help with game?
i already made a timer, that isnt the problem, the problem is to make the targets time before disappearing prolonged
Dreadnought
Posted: Mon Dec 05, 2011 9:33 pm Post subject: Re: help with game?
The code you posted doesn't even reliably make the targets appear. Not to mention that after 27 seconds targets will never appear. You should probably have a look at these issues.
To keep targets on the screen for longer periods you should use timers of some sort like Aange10 said. I know you have one in your code (sorta) but it does absolutely nothing except change a variable that you never use anywhere else. Its not enough to throw a few lines that can be used as a timer and hope it works. You have to actually make use of your variable. For example, check if Time.Elapsed is 500 greater than your timer variable to see if 0.5 seconds have passed.
Also, you can have more than one timer.
programmer1337
Posted: Tue Dec 06, 2011 7:48 am Post subject: Re: help with game?