
-----------------------------------
Alex C.
Tue Jan 10, 2012 9:13 pm

Need help with &quot;shooting a projectile&quot; and a &quot;password menu&quot;
-----------------------------------
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

 :vi: 

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)




View.Set ("nobuttonbar,offscreenonly")
var x, y : int
x := 100
y := 100
var chars : array char of boolean
loop
    Input.KeyDown (chars)
    if chars (KEY_UP_ARROW) then
        y := y + 3
    end if
    if chars (KEY_RIGHT_ARROW) then
        x := x + 3
    end if
    if chars (KEY_LEFT_ARROW) then
        x := x - 3
    end if
    if chars (KEY_DOWN_ARROW) then
        y := y - 3
    end if
    if chars (/*SHOOTING KEY*/) then
       %SHOOTING CODE
    end if
    drawfilloval (x, y, 40, 40, 56)
    delay (10)
    put "Use the arrow keys to move the ball, and press ESC to exit"
    View.Update
    cls
end loop



 for a password screen... yeah no clue :(

Please specify what version of Turing you are using

 um... it's 4.1.1

-----------------------------------
chipanpriest
Tue Jan 10, 2012 9:32 pm

Re: Need help with &quot;shooting a projectile&quot; and a &quot;password menu&quot;
-----------------------------------
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:

var answer : string
get answer : *
if answer = whateverthepasswordis then
cheat := true
end if


-----------------------------------
Alex C.
Tue Jan 10, 2012 9:39 pm

RE:Need help with &quot;shooting a projectile&quot; and a &quot;password menu&quot;
-----------------------------------
alright, but when I try to shoot the projectile & move, the shot follows the character... :(

-----------------------------------
Tony
Tue Jan 10, 2012 9:48 pm

RE:Need help with &quot;shooting a projectile&quot; and a &quot;password menu&quot;
-----------------------------------
things like
[code]
var x, y : int
[/code]
are ambiguous. Use descriptive names, such as
[code]
var character_x, character_y : int
[/code]
If you find yourself drawing projectiles using the values of character_x, then that is a problem.

-----------------------------------
Alex C.
Tue Jan 10, 2012 10:27 pm

RE:Need help with &quot;shooting a projectile&quot; and a &quot;password menu&quot;
-----------------------------------
thanks! :D

-----------------------------------
Velocity
Wed Jan 11, 2012 12:18 am

RE:Need help with &quot;shooting a projectile&quot; and a &quot;password menu&quot;
-----------------------------------
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?.

-----------------------------------
Tony
Wed Jan 11, 2012 1:09 am

Re: RE:Need help with &quot;shooting a projectile&quot; and a &quot;password menu&quot;
-----------------------------------
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).

-----------------------------------
chipanpriest
Wed Jan 11, 2012 7:05 am

Re: Need help with &quot;shooting a projectile&quot; and a &quot;password menu&quot;
-----------------------------------
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,


    if chars (/*SHOOTING KEY*/) then 
       %This would need a separate x and y variable than the ones you are using such as bulletx and bullety
    end if 


-----------------------------------
Velocity
Wed Jan 11, 2012 8:40 am

RE:Need help with &quot;shooting a projectile&quot; and a &quot;password menu&quot;
-----------------------------------
tony, in which case would you use one over the other ? Ima look around

-----------------------------------
tg851
Wed Jan 11, 2012 11:09 am

Re: Need help with &quot;shooting a projectile&quot; and a &quot;password menu&quot;
-----------------------------------
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:

var answer : string
get answer : *
if answer = whateverthepasswordis then
cheat := true
end if


its actually 
var answer : string
get answer : *
if answer = "whateverthepasswordis" then
cheat := true
end if

otherwise it will look for a nonexistent variable, instead of checking the string
also
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)

-----------------------------------
Tony
Wed Jan 11, 2012 12:27 pm

Re: RE:Need help with &quot;shooting a projectile&quot; and a &quot;password menu&quot;
-----------------------------------
tony, in which case would you use one over the other ? Ima look around
When the following behaviour difference matters
[code]
#include 

int foo = 0;

int& var() {
	std::cout 