Computer Science Canada help with game? |
Author: | programmer1337 [ 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>
|
Author: | RandomLetters [ 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? |
Author: | programmer1337 [ 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 |
Author: | RandomLetters [ 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.
Alternatively, you can represent targets using shapes or hitboxes, such as a rectangle, and use math to check if the coordinates of the cursor is within a hitbox. http://compsci.ca/v3/viewtopic.php?t=75&highlight=collision [/code] |
Author: | programmer1337 [ Sat Dec 03, 2011 3:36 pm ] | ||
Post subject: | Re: help with game? | ||
this is my current code for mous control, it keeps lagging, can you guys help me?
|
Author: | DemonWasp [ Sat Dec 03, 2011 3:44 pm ] | ||
Post subject: | Re: help with game? | ||
programmer1337 @ Sat Dec 03, 2011 3:36 pm wrote:
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". |
Author: | programmer1337 [ 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? |
Author: | RandomLetters [ 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. |
Author: | programmer1337 [ Sat Dec 03, 2011 3:57 pm ] |
Post subject: | Re: help with game? |
can you please just start me off, with the counter? |
Author: | RandomLetters [ Sat Dec 03, 2011 7:48 pm ] | ||
Post subject: | RE:help with game? | ||
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 |
Author: | programmer1337 [ 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?
|
Author: | Aange10 [ 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
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. |
Author: | programmer1337 [ 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 |
Author: | ProgrammingFun [ 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?) |
Author: | programmer1337 [ 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 |
Author: | Aange10 [ 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. |
Author: | RandomLetters [ 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. |
Author: | programmer1337 [ 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.
|
Author: | Aange10 [ 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'.) |
Author: | programmer1337 [ 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 ![]()
it doesnt put c and it doesnt do anything lol |
Author: | Aange10 [ 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. |
Author: | programmer1337 [ Mon Dec 05, 2011 7:14 pm ] | ||
Post subject: | Re: help with game? | ||
i tried doing this
it still doesnt work? |
Author: | Aange10 [ 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 |
Author: | programmer1337 [ 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 ![]() |
Author: | programmer1337 [ 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
|
Author: | Aange10 [ Mon Dec 05, 2011 8:04 pm ] |
Post subject: | RE:help with game? |
The attachment above shows you how to make a timer. |
Author: | programmer1337 [ 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 |
Author: | Dreadnought [ 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. |
Author: | programmer1337 [ Tue Dec 06, 2011 7:48 am ] |
Post subject: | Re: help with game? |
ohh thank you i actually find out how to do it |