Jump to content

Help - Simple code


Recommended Posts

I am currently making a very very simple game, it doesnt need to be great but it needs to work and im having problems finding the code for some things. I have an image which is a target, it moves around the screen and i have a much smaller image which is a crosshair(stays in the middle of the screen), i also have a button which is suposed to be the shoot button.

I have made a small image appear when i click the button but i need to make it disapear very quickly after, i need this to appear and disapear everytime i click the button, this is the first thing i need help with.

Secondly i need to increase a variable i called score by 1 everytime the button is clicked while the crosshair is over the target.

Very simple i know but im really not a good programer and need help with the code, thanks :)

Re: This is in delphi

Edited by Umpa
Link to comment
Share on other sites


what language are you doing?

do you have an environment class?

i recently made a space invaders game in java, so it sounds almost exactly like what you are trying to do.

the score counter would have to be a variable in the environment class.

every object need to be in the environment.

you will need to make a new method and a die method for everything you have.

Link to comment
Share on other sites

yeah ill get one of the form but i wont bother with the code because there isnt much there and its probly wrong :unsure:

is there any code u know to hide an image after a certain amount of time?

Link to comment
Share on other sites

right, dont have it with me like i thought i did but here is what it looked like, very simple, begin button starts the target moving and shoot is suposed to add to score if the circle is over the target but i cant find out how to tell if the target is the same position as the crosshair.

form.jpg

Link to comment
Share on other sites

i tried that but i couldnt get it to work :S could u tell me what code to put in the timer? if any, or do i just change properties or somethin, as i said im really not very good with delphi, sorry. :(

Link to comment
Share on other sites

Put a Timer object on your Form (from the System palette), double-click it and if you type the following ...

Image1.Visible := not Image1.Visible

... it will make the Image flash on and off in 1 second (1000 millisecond) intervals.

(Assuming that in Delphi 6, a Timer is enabled by default - I only have Delphi 7)

Link to comment
Share on other sites

well ive not used the tool much before so i wont be able to work it out myself :P, i messed about with the code and tried somethin like, if image is visible do image.hide but that didnt work either, meh i dunno :/

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...