Computer Science Canada Need help with "shooting a projectile" and a "password menu" |
Author: | Alex C. [ Tue Jan 10, 2012 9:13 pm ] | ||
Post subject: | Need help with "shooting a projectile" and a "password menu" | ||
What is it you are trying to achieve? 1) Have a image fire a projectile vertically 2) Create a password entry area (for cheats and such unlockables =D) What is the problem you are having? I have no knowledge on either of those topics... =( Describe what you have tried to solve this problem Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) <Answer Here>
for a password screen... yeah no clue Please specify what version of Turing you are using um... it's 4.1.1 |
Author: | chipanpriest [ Tue Jan 10, 2012 9:32 pm ] | ||
Post subject: | Re: Need help with "shooting a projectile" and a "password menu" | ||
You seem to already know how to shoot a projectile given your code. For the password thing, you can do a simple get code. Do something like:
|
Author: | Alex C. [ Tue Jan 10, 2012 9:39 pm ] |
Post subject: | RE:Need help with "shooting a projectile" and a "password menu" |
alright, but when I try to shoot the projectile & move, the shot follows the character... |
Author: | Tony [ Tue Jan 10, 2012 9:48 pm ] | ||||
Post subject: | RE:Need help with "shooting a projectile" and a "password menu" | ||||
things like
are ambiguous. Use descriptive names, such as
If you find yourself drawing projectiles using the values of character_x, then that is a problem. |
Author: | Alex C. [ Tue Jan 10, 2012 10:27 pm ] |
Post subject: | RE:Need help with "shooting a projectile" and a "password menu" |
thanks! |
Author: | Velocity [ Wed Jan 11, 2012 12:18 am ] |
Post subject: | RE:Need help with "shooting a projectile" and a "password menu" |
instead of y := y + 5 Write y += 5 its the same thing, its more advanced, saves you .5 milliseconds and it looks pro. You can do it for any operator. For the password... Seems like you have knowlendge of arrays so make an array say a max 3 range, and call each variable from the array and declare that variable with a password. Any text that u decide And then make a put and get statement and write if password say (1) of your array = true then .... Whatever the password does. Oh and do you still need help with shooting projectiles?. |
Author: | Tony [ Wed Jan 11, 2012 1:09 am ] |
Post subject: | Re: RE:Need help with "shooting a projectile" and a "password menu" |
Velocity @ Wed Jan 11, 2012 12:18 am wrote: instead of y := y + 5
Write y += 5 its the same thing It's almost the same thing. Fun exercise -- find a case where the difference matters. (For most practical purposes, this difference doesn't matter). |
Author: | chipanpriest [ Wed Jan 11, 2012 7:05 am ] | ||
Post subject: | Re: Need help with "shooting a projectile" and a "password menu" | ||
Your shot probably follows your player because you are using the same variables for the coordinates of your player and the coordinates of the shot. In order to make the shot not follow your player, you would need separate variables for the player and the shot; for example,
|
Author: | Velocity [ Wed Jan 11, 2012 8:40 am ] |
Post subject: | RE:Need help with "shooting a projectile" and a "password menu" |
tony, in which case would you use one over the other ? Ima look around |
Author: | tg851 [ Wed Jan 11, 2012 11:09 am ] | ||||
Post subject: | Re: Need help with "shooting a projectile" and a "password menu" | ||||
chipanpriest @ Tue Jan 10, 2012 9:32 pm wrote: You seem to already know how to shoot a projectile given your code. For the password thing, you can do a simple get code. Do something like:
its actually
otherwise it will look for a nonexistent variable, instead of checking the string also Tony @ Wed Jan 11, 2012 1:09 am wrote: Velocity @ Wed Jan 11, 2012 12:18 am wrote: instead of y := y + 5
Write y += 5 its the same thing It's almost the same thing. Fun exercise -- find a case where the difference matters. (For most practical purposes, this difference doesn't matter). x= instead of x:= makes the argument flimsy if x go a change from floor or another command that changes it to something other that int(like from int to true)the error module will throw a fit(I think) |
Author: | Tony [ Wed Jan 11, 2012 12:27 pm ] | ||
Post subject: | Re: RE:Need help with "shooting a projectile" and a "password menu" | ||
Velocity @ Wed Jan 11, 2012 8:40 am wrote: tony, in which case would you use one over the other ? Ima look around
When the following behaviour difference matters
|
Author: | DemonWasp [ Wed Jan 11, 2012 2:41 pm ] | ||
Post subject: | RE:Need help with "shooting a projectile" and a "password menu" | ||
Given that the context is a Turing Help thread, this may be a more pertinent example:
|
Author: | Tony [ Wed Jan 11, 2012 3:44 pm ] | ||
Post subject: | RE:Need help with "shooting a projectile" and a "password menu" | ||
@DemonWasp this looks like an order-of-operation difference, rather than assignment operators. The modify() function is equivalent to ++v. The important difference with += is that the evaluation takes place only once. This shouldn't even matter for simple variables, as I'd expect a good compiler to rewrite that in whichever version is faster (I'm expecting speed difference to be on the order of ++a vs. a++). This difference could matter if the variable comes from an expression. Here's a Turing example:
|
Author: | DemonWasp [ Wed Jan 11, 2012 5:16 pm ] | ||||
Post subject: | RE:Need help with "shooting a projectile" and a "password menu" | ||||
Apparently I'd forgotten just how C-like Turing really can be. Here's your example, translated:
In any case, both of these are relatively benign: you have to explicitly say that you wanted something done twice. They only become evil if you start defining macros so that they look like plain variables:
|
Author: | Velocity [ Thu Jan 12, 2012 6:01 pm ] |
Post subject: | RE:Need help with "shooting a projectile" and a "password menu" |
oooh, okay but tony, i was just talking about how the y+=5 would be better than y := y + 5 in this case |
Author: | Raknarg [ Thu Jan 12, 2012 8:54 pm ] |
Post subject: | RE:Need help with "shooting a projectile" and a "password menu" |
That wasnt the point. The point was that you're missing the subtlety of programming, where small differences, although they appear to be similar, are't exactly the same. Can be confused with trolling. |
Author: | Aange10 [ Thu Jan 12, 2012 9:35 pm ] | ||
Post subject: | RE:Need help with "shooting a projectile" and a "password menu" | ||
Is very interesting, but is that really a subtly in the increment operand, or common sense? += would definitely be superior in this situation, in my opinion. But as writing code myself, if I saw this problem, I would simply store (Rand.Int (1,10)) into a temp variable. |
Author: | Raknarg [ Thu Jan 12, 2012 9:53 pm ] |
Post subject: | RE:Need help with "shooting a projectile" and a "password menu" |
In a lot of cases it wont make a difference, anyways. |
Author: | evildaddy911 [ Fri Jan 13, 2012 4:36 pm ] |
Post subject: | RE:Need help with "shooting a projectile" and a "password menu" |
its simply quicker to type |
Author: | mirhagk [ Fri Jan 13, 2012 6:03 pm ] |
Post subject: | RE:Need help with "shooting a projectile" and a "password menu" |
and as Tony pointed out, technically could be slightly faster (although probably not if there is a good compiler *cough* not turing *cough*) |