bullets and boundaires
Author |
Message |
Marshmellow01
|
Posted: Tue Jun 05, 2007 11:45 pm Post subject: bullets and boundaires |
|
|
I am not sure what i am doing wrong
the bullets follow the same movements as the player and
i tried to create bullets and manage to get two different ones
('m') this key is suppose to make player 1 shoot but it makes a circle that moves in the same direction as the player and only appears when you press the button, so it doesnt remain on the screen after pressing it
('l') this key shoots up but it shows a pillar and also moves with the player
it seems more of a laser then a bullet
the boundaires for top and bottem dont stop the player from going any further off the screen
i am not sure what i am doing wrong and how to make the bullets work please help me out if u can ty , my project is due in two days
copy and paste to a turing file if u want to see what i am trying to explain
Turing: |
%the game codes
setscreen ("graphics:650;500")
setscreen ("offscreenonly")
var player1 : array char of boolean
var x : int := 300
var y : int := 1
%bullets%
var bulletx, clearx : int
var bullety, cleary : int
loop
cls
Input.KeyDown (player1 )
if player1 (KEY_UP_ARROW) then
y + = 5
end if
if player1 (KEY_DOWN_ARROW) then
y - = 5
end if
if player1 (KEY_RIGHT_ARROW) then
x + = 5
end if
if player1 (KEY_LEFT_ARROW) then
x - = 5
end if
delay (50)
Input.KeyDown (player1 )
if player1 ('m') then
bulletx :=x + 0
bullety :=y + 20
Draw.Oval (bulletx, bullety, 10, 10, red)
end if
%boundaries
if x = maxx then
x := 0
elsif x = 0 then
x := maxx
elsif y = 100 then
y := 0
elsif y = 0 then
y := 100
end if
%shooting
bulletx := x
bullety := y
clearx := x - 5
cleary := y - 5
if player1 ('l') then
loop
exit when bulletx = 0 and bullety = 500 or bulletx = 0 or bullety = 500
drawfilloval (bulletx, bullety, 5, 5, red)
drawfilloval (clearx, cleary, 5, 5, white)
bulletx := bulletx + 0
bullety := bullety + 1
clearx := bulletx - 0
cleary := bullety + 1
end loop
end if
Draw.Oval (x, y, 5, 5, black)
View.Update
for i : 1 .. 10
Time.Delay (1000)
drawfilloval (15, 15, 15, 15, red)
end for |
Edited by Clayton: Keep the flourescent colours to a minimum please |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Mazer
|
Posted: Wed Jun 06, 2007 1:03 pm Post subject: RE:bullets and boundaires |
|
|
Your problem is that you're only drawing the bullet when m is pressed. You are short on time, and short on understanding. This probably wasn't a good choice for a project, but you've got to bear with it now.
Simplify things by only allowing one bullet at a time. Represent this bullet with an x value, a y value, an x velocity, a y velocity, and whether the bullet is "live" or not.
Start the bullet off as dead (false). When you're checking your fire button, check if the button is pressed AND if the bullet is dead. If that condition is true, set the bullet to live (true) and set the x and y to the player's position. Now give it a velocity depending on the direction the player is facing: if right, x velocity = 1, y velocity = 0; if up, x velocity = 0, y velocity = 1; etc. Use larger values if you want it moving faster.
When you're drawing things, check if the bullet is live. If so, add the x velocity to the x position and the y velocity to the y position, then draw the bullet.
You'll also want a counter or something for the bullet to see how long it's been alive. Make sure that counter is set to 0 when the bullet is created and incremented each time it's drawn.
And get rid of that damned inner loop. |
|
|
|
|
|
Marshmellow01
|
Posted: Wed Jun 06, 2007 4:20 pm Post subject: RE:bullets and boundaires |
|
|
eh XD im not rly sure how to do that .. total nub at this XD
i looked on reference help thing
var bulletx:int
var bullety:int
var bulletxvelocity :int
var bulletyvelocity :int
var dead : boolean := false
var word : int
for i : 1 .. 10
get word
found := found or word = "gold"
end for
if live = true then
put "Found 'gold' in the ten words"
end if
lol not rly sure how i am suppose to type it up
...i feel so hopeless XD |
|
|
|
|
|
Mazer
|
Posted: Wed Jun 06, 2007 5:10 pm Post subject: RE:bullets and boundaires |
|
|
I'll be blunt: you should feel hopeless.
Really, what the hell does gold have to do with anything? I don't think you should've waited so long to work on this project, and I don't think you should've chosen a project as difficult as this if you have no idea what you're doing.
Best of luck. |
|
|
|
|
|
Marshmellow01
|
Posted: Wed Jun 06, 2007 5:18 pm Post subject: RE:bullets and boundaires |
|
|
lol XD it was on the turing refernec thing
well ty for the help i guess lol i might just abandon it and start on a easier project
that i can finish soon lol maybe pong or something
well ty for the help i m just gona try to figure it out on my spare time then |
|
|
|
|
|
|
|