Posted: Thu Feb 10, 2005 6:22 pm Post subject: Lots and lots of errors...
Okay ima make a list of errors that I have.
(NOTE you will have to download the picture)
code:
var background : int := Pic.FileNew ("Background.jpg")
var x, y : int := 200
var ch : string (1)
var c, v, z : int := 0
View.Set ("graphics")
Pic.Draw (background, 0, 0, picCopy)
procedure movement
loop
getch (ch)
if ch = "w" or ch = "W" then
y := y + 5
elsif ch = "s" or ch = "S" then
y := y - 5
elsif ch = "d" or ch = "D" then
x := x + 5
elsif ch = "a" or ch = "A" then
x := x - 5
end if
Pic.Draw (background, 0, 0, picCopy)
Draw.Oval (x, y, 15, 15, red)
Draw.FillOval (x, y, 14, 14, brightred)
View.Update
end loop
end movement
process gun
loop
Mouse.Where (c, v, z)
Draw.Line (x, y, c, v, red)
end loop
end gun
fork gun
movement
First of all Ill tell you what I want it to do. Have the little cicle move around (Later resemble a person) and have him face any direction that the mouse is pointing.
I got the circle to move with Getch. It flickers.
The gun faces the way it is supposed to, but it goes where the mouse is, and overlaps the person (I can fix the overlap).
If you can help me fix any or all of these it will be greatly appreciated
Background.JPG
Description:
Filesize:
96.35 KB
Viewed:
2902 Time(s)
Sponsor Sponsor
Bacchus
Posted: Thu Feb 10, 2005 7:26 pm Post subject: (No subject)
code:
var x, y : int := 200
var ch : array char of boolean
var c, v, z : int := 0
View.Set ("graphics,offscreenonly") %forgot to put offscreenonly
%ddint want to get the background sooo... took it out
procedure movement
loop
cls
Input.KeyDown (ch) %no waiting and blibking light yuk :P
if ch ('w') then
y += 5
elsif ch ('s') then
y -= 5
elsif ch ('d') then
x += 5
elsif ch ('a') then
x -= 5
end if
Mouse.Where (c, v, z) %processes r evil
if z~=0 then
Draw.Line (x, y, c, v, red)
end if
Draw.FillOval (x, y, 14, 14, brightred)
Draw.Oval (x, y, 14, 14, red)
View.Update
delay(10)
end loop
end movement
movement
not sure if that how u wanted... but hey some fixed
Flikerator
Posted: Thu Feb 10, 2005 8:38 pm Post subject: (No subject)
Sweet. Thanks for all the help. Its so much smoother and it doesn't blink like crazy thanks. Now I just have to make a bunch of different looking guns in turing (Shotgun, semi, auto, sniper) and have them able to rotate towards the mouse ^^
Ill have to work on that tommorow though cause I dun have turing on this comp (Checked it when I still have other comp).
Thanks again. (Its for Zombie Mass'Acres)
Flikerator
Posted: Fri Feb 11, 2005 4:14 pm Post subject: New problem
My gun is nearly complete! But before I finish it to fire in any direction I need a little help.
I want the bullets to stop flickering, and I want there to be delay between firing. I was thinking that mabey putting in a gun sound that plays out before you can do anything except move. I dunno I need some help to stop the flickering and put some delay between firing. You will probably want to download the background because it symbolizes the ground which I wil have in my game. I could have just erased the bullet with white instead but I have a multicoloured background so its a bit different.
code:
var x, y : int := 200
var ch : array char of boolean
var c, v, z : int := 0
var background : int := Pic.FileNew ("Pictures/Background.jpg")
View.Set ("graphics:640,439,offscreenonly")
process bullet (xx, yy : int)
if c > x then
for i : 1 .. 400 by 4
Draw.FillOval (xx + 15 + i, yy, 5, 1, yellow)
delay (10)
View.Update
end for
end if
end bullet
procedure movement
loop
Pic.Draw (background, 0, 0, picCopy)
Input.KeyDown (ch)
if ch ('w') then
if y < maxy - 20 then
y += 5
end if
elsif ch ('s') then
if y > 20 then
y -= 5
end if
elsif ch ('d') then
if x < maxx - 20 then
x += 5
end if
elsif ch ('a') then
if x > 20 then
x -= 5
end if
end if
Mouse.Where (c, v, z)
Draw.Line (x, y, c, v, yellow)
if z = 1 then
fork bullet (x, y)
end if
Draw.FillOval (x, y, 14, 14, brightred)
Draw.Oval (x, y, 14, 14, red)
View.Update
delay (20)
end loop
end movement
movement
Cervantes
Posted: Fri Feb 11, 2005 4:31 pm Post subject: (No subject)
Don't use a process. Especially if it means having two or more View.Updates.
Flikerator
Posted: Fri Feb 11, 2005 4:32 pm Post subject: (No subject)
What else can I do? If I put it in the procedure thing I got going on then the bullet goes its path and then I can move again.
UPDATED
-----------
code:
var x, y : int := 200
var ch : array char of boolean
var c, v, z : int := 0
var background : int := Pic.FileNew ("Pictures/Background.jpg")
View.Set ("graphics:640,439,offscreenonly")
process bullet (xx, yy : int)
if c > x and y + 10 > v and y - 10 < v then
for i : 1 .. 400 by 4
Draw.FillOval (xx + 15 + i, yy, 5, 1, yellow)
delay (10)
View.Update
end for
elsif c < x and y + 10 > v and y - 10 < v then
for i : 1 .. 400 by 4
Draw.FillOval (xx - 15 - i, yy, 5, 1, yellow)
delay (10)
View.Update
end for
elsif v > y and x + 10 > c and x - 10 < c then
for i : 1 .. 400 by 4
Draw.FillOval (xx, yy + 15 + i, 1, 5, yellow)
delay (10)
View.Update
end for
elsif v < y and x + 10 > c and x - 10 < c then
for i : 1 .. 400 by 4
Draw.FillOval (xx, yy - 15 - i, 1, 5, yellow)
delay (10)
View.Update
end for
end if
end bullet
procedure movement
loop
Pic.Draw (background, 0, 0, picCopy)
Input.KeyDown (ch)
if ch ('w') then
if y < maxy - 20 then
y += 5
end if
elsif ch ('s') then
if y > 20 then
y -= 5
end if
elsif ch ('d') then
if x < maxx - 20 then
x += 5
end if
elsif ch ('a') then
if x > 20 then
x -= 5
end if
end if
Mouse.Where (c, v, z)
Draw.Line (x, y, c, v, yellow)
if z = 1 then
fork bullet (x, y)
end if
Draw.FillOval (x, y, 14, 14, brightred)
Draw.Oval (x, y, 14, 14, red)
View.Update
delay (20)
end loop
end movement
movement
Cervantes
Posted: Fri Feb 11, 2005 6:12 pm Post subject: (No subject)
Flikerator wrote:
What else can I do? If I put it in the procedure thing I got going on then the bullet goes its path and then I can move again.
Make the bullet an object (or emulate an object) and update it based on its own properties.
Learning records would be good for this. Check the tutorial section.
-Cervantes
Flikerator
Posted: Fri Feb 11, 2005 6:49 pm Post subject: (No subject)
Search which tutorial and what would it fix?
UPDATE CODE - Notice that you can move with the numpad including digonal. You can currently shoot in 4 direction with a small degree of give (Ei 10 pixels either direction)
You have to click to fire also.
code:
var x, y : int := 200
var ch : array char of boolean
var c, v, z : int := 0
var background : int := Pic.FileNew ("Pictures/Background.jpg")
View.Set ("graphics:640,439,offscreenonly")
process bullet (xx, yy : int)
if c > x and y + 10 > v and y - 10 < v then
for i : 1 .. 400 by 4
Draw.FillOval (xx + 15 + i, yy, 5, 1, yellow) %90*
delay (10)
View.Update
end for
elsif c < x and y + 10 > v and y - 10 < v then
for i : 1 .. 400 by 4
Draw.FillOval (xx - 15 - i, yy, 5, 1, yellow) %270*
delay (10)
View.Update
end for
elsif v > y and x + 10 > c and x - 10 < c then
for i : 1 .. 400 by 4
Draw.FillOval (xx, yy + 15 + i, 1, 5, yellow) %360*
delay (10)
View.Update
end for
elsif v < y and x + 10 > c and x - 10 < c then
for i : 1 .. 400 by 4
Draw.FillOval (xx, yy - 15 - i, 1, 5, yellow) %180*
delay (10)
View.Update
end for
end if
end bullet
procedure movement
loop
Pic.Draw (background, 0, 0, picCopy)
Input.KeyDown (ch)
if ch ('w') or ch ('8') then
if y < maxy - 20 then
y += 5
end if
elsif ch ('s') or ch ('2') then
if y > 20 then
y -= 5
end if
elsif ch ('d') or ch ('6') then
if x < maxx - 20 then
x += 5
end if
elsif ch ('a') or ch ('4') then
if x > 20 then
x -= 5
end if
elsif ch ('7') then
if y < maxy - 20 and x > 20 then
y += 2
x -= 2
end if
elsif ch ('9') then
if y < maxy - 20 and x < maxx - 20 then
y += 2
x += 2
end if
elsif ch ('3') then
if y > 20 and x < maxx - 20 then
y -= 2
x += 2
end if
elsif ch ('1') then
if y > 20 and x > 20 then
x -= 2
y -= 2
end if
end if
Mouse.Where (c, v, z)
Draw.Line (x, y, c, v, yellow)
if z = 1 then
fork bullet (x, y)
end if
Draw.FillOval (x, y, 14, 14, brightred)
Draw.Oval (x, y, 14, 14, red)
View.Update
delay (20)
end loop
end movement
movement
Things I need to work:
- Bullets flickering
- Delay BETWEEN firing bullets. That more then the flickering.
- The line goes all the way to the mouse. I need it to go only say, 10 pixles towards it.
Sponsor Sponsor
Cervantes
Posted: Fri Feb 11, 2005 6:58 pm Post subject: (No subject)
Flikerator wrote:
Search which tutorial
Cervantes wrote:
Learning records would be good for this. Check the tutorial section.
flikerator wrote:
and what would it fix?
Cervantes wrote:
Don't use a process.
To elaborate, it will fix the whole needing-to-use-a-process crap.
Also, I'm not sure if you WANT to only be able to shoot in four directions, but you could easily make your bullet fire at any angle if you make the bullet an object and don't use processes.
Flikerator
Posted: Fri Feb 11, 2005 7:02 pm Post subject: (No subject)
Alright thanks I just have to find the tutorial then ill test it out. Thanks for the help btw.
EDIT - I checked out the tutorial called "records" and I didn't understand it. Could you give me an example different from the one found there. I looked in turing reference and I don't understand it eiteher, well it gets an error so >.<
Cervantes
Posted: Fri Feb 11, 2005 7:50 pm Post subject: (No subject)
Records are very simple. Types must be a little bit more difficult.
Let's just deal with records. We don't need types for this.
if we declare a variable, bullet, it can only ever have one value. That limits us, because we need information about the bullets x and y position, as well as its x and y velocity.
So, to solve this, we make a record.
code:
var bullet :
record
x : real
y : real
vx : real
vy : real
end record
Now, we have our variable, "bullet", but we can store much more information with it.
It's pretty simple. If you don't get it, come on IRC. compsci.ca on afternet. You can always click Hikaru's link for simplicity. Or you can MSN me (check the msn icon).
-Cervantes
Flikerator
Posted: Fri Feb 11, 2005 8:17 pm Post subject: (No subject)
Okay that sounds a little better. But how do I give them values and use them to move the bullet? (I added you to msn, if it didnt work then add me at Doubleultranova@hotmail.com )
Thanks for all the help : D Im learning lots!
Bacchus
Posted: Sat Feb 12, 2005 12:28 am Post subject: (No subject)
to give them values you would do something like:
code:
var bullet:
record
x,y,vx,vy:real
end record
bullet.x:=10 %notice the . in there
bullet.y:=10
bullet.vx:=2.5
bullet.vy:=2.5
View.Set ("offscreenonly")
loop
cls
bullet.x+=bullet.vx
bullet.y+=bullet.vy
drawfilloval (round(bullet.x),round(bullet.y),5,5,2) %<-- the round is to make the real value an int value
View.Update
delay(10)
end loop
im not that good at explanations
Flikerator
Posted: Sat Feb 12, 2005 3:15 pm Post subject: (No subject)
Alright now I finnaly understand records BUT
If I put that in then it does the animation of the bullet and doesnt let me do anything untill its done. I would have to put it into a process, which eliminates the whole idea behind me making the bullet a record...lolz
I also need to put a delay between firing each bullet. Which Im thinking you have to press the mouse down and then when it goes up it fires again? I unno thats why I need help ^^
Thanks for that Bacchus cause now I know how to work records completely (as far as I know.)
Bacchus
Posted: Sat Feb 12, 2005 3:56 pm Post subject: (No subject)
no prob. but still no processes. they suk and r evil
try adding something like this in ur game
code:
var bullet
record
x,y,vx,vy:int
fire:boolean
end record
bullet.fire:=false
var mx,my,mb:int
loop
cls
Mouse.Where(mx,my,mb)
if mb~=0 & ~bullet.fire then %with boolean u can just put variable name for true or a ~ in front for false
bullet.fire:=true
bullet.x:=10 %or ur starting point for byullet
bullet.y:=10 %same
elsif bullet.fire then
bullet.x+=bullet.vx
bullet.y+=bullet.vy
end if
View.Update % yes i kno im missing other bit, just an example
end loop