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

Username:   Password: 
 RegisterRegister   
 help with game?
Index -> Programming, Turing -> Turing Help
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Aange10




PostPosted: 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
Sponsor
sponsor
RandomLetters




PostPosted: 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




PostPosted: 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

    rndInt3 := Rand.Int (1000, 10000)
    rndInt := Rand.Int (10, 1150)
    rndInt1 := Rand.Int (10, 550)
   

     c := 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 := 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




PostPosted: 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'.)



Reseting Time.T
 Description:

Download
 Filename:  Reseting Time.T
 Filesize:  495 Bytes
 Downloaded:  78 Time(s)

programmer1337




PostPosted: 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 Sad 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




PostPosted: 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




PostPosted: 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




PostPosted: 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
Sponsor
sponsor
programmer1337




PostPosted: 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 Wink sorry
programmer1337




PostPosted: 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
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
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

if Time.Elapsed() = 5000 then
    Draw.FillOval (rndInt, rndInt1, 40, 40, brightred)
    Draw.FillOval (rndInt, rndInt1, 30, 30, white)
    Draw.FillOval (rndInt, rndInt1, 10, 10, brightred)
    delay(100)
    elsif Time.Elapsed() = 7950 then
    Draw.FillOval (rndInt, rndInt1, 40, 40, brightred)
    Draw.FillOval (rndInt, rndInt1, 30, 30, white)
    Draw.FillOval (rndInt, rndInt1, 10, 10, brightred)
    delay(100)
    elsif Time.Elapsed() = 8500 then
    Draw.FillOval (rndInt, rndInt1, 40, 40, brightred)
    Draw.FillOval (rndInt, rndInt1, 30, 30, white)
    Draw.FillOval (rndInt, rndInt1, 10, 10, brightred)
    delay(100)
    elsif Time.Elapsed() = 10000 then
    Draw.FillOval (rndInt, rndInt1, 40, 40, brightred)
    Draw.FillOval (rndInt, rndInt1, 30, 30, white)
    Draw.FillOval (rndInt, rndInt1, 10, 10, brightred)
    delay(100)
    elsif Time.Elapsed() = 13000 then
    Draw.FillOval (rndInt, rndInt1, 40, 40, brightred)
    Draw.FillOval (rndInt, rndInt1, 30, 30, white)
    Draw.FillOval (rndInt, rndInt1, 10, 10, brightred)
    elsif Time.Elapsed() = 17000 then
    Draw.FillOval (rndInt, rndInt1, 40, 40, brightred)
    Draw.FillOval (rndInt, rndInt1, 30, 30, white)
    Draw.FillOval (rndInt, rndInt1, 10, 10, brightred)
    elsif Time.Elapsed() = 19200 then
    Draw.FillOval (rndInt, rndInt1, 40, 40, brightred)
    Draw.FillOval (rndInt, rndInt1, 30, 30, white)
    Draw.FillOval (rndInt, rndInt1, 10, 10, brightred)
    elsif Time.Elapsed() = 22000 then
    Draw.FillOval (rndInt, rndInt1, 40, 40, brightred)
    Draw.FillOval (rndInt, rndInt1, 30, 30, white)
    Draw.FillOval (rndInt, rndInt1, 10, 10, brightred)
    elsif Time.Elapsed() = 24500 then
    Draw.FillOval (rndInt, rndInt1, 40, 40, brightred)
    Draw.FillOval (rndInt, rndInt1, 30, 30, white)
    Draw.FillOval (rndInt, rndInt1, 10, 10, brightred)
    elsif Time.Elapsed() = 27000 then
    Draw.FillOval (rndInt, rndInt1, 40, 40, brightred)
    Draw.FillOval (rndInt, rndInt1, 30, 30, white)
    Draw.FillOval (rndInt, rndInt1, 10, 10, brightred)
    end if
    View.Update
if count1 = 27000 then
count1 := 0
c := 0
end if

    exit when chars (KEY_ESC)
end loop

Aange10




PostPosted: Mon Dec 05, 2011 8:04 pm   Post subject: RE:help with game?

The attachment above shows you how to make a timer.
programmer1337




PostPosted: 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




PostPosted: 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




PostPosted: Tue Dec 06, 2011 7:48 am   Post subject: Re: help with game?

ohh thank you i actually find out how to do it
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 2 of 2  [ 29 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: