
-----------------------------------
Flikerator
Thu Feb 10, 2005 6:22 pm

Lots and lots of errors...
-----------------------------------
Okay ima make a list of errors that I have. 
(NOTE you will have to download the picture)


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

-----------------------------------
Bacchus
Thu Feb 10, 2005 7:26 pm


-----------------------------------
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
Thu Feb 10, 2005 8:38 pm


-----------------------------------
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
Fri Feb 11, 2005 4:14 pm

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.


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
Fri Feb 11, 2005 4:31 pm


-----------------------------------
Don't use a process.  Especially if it means having two or more View.Updates.

-----------------------------------
Flikerator
Fri Feb 11, 2005 4:32 pm


-----------------------------------
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
-----------

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
Fri Feb 11, 2005 6:12 pm


-----------------------------------

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
Fri Feb 11, 2005 6:49 pm


-----------------------------------
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.

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.

-----------------------------------
Cervantes
Fri Feb 11, 2005 6:58 pm


-----------------------------------

Search which tutorial


Learning records would be good for this.  Check the tutorial section.



and what would it fix? 


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
Fri Feb 11, 2005 7:02 pm


-----------------------------------
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
Fri Feb 11, 2005 7:50 pm


-----------------------------------
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.


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
Fri Feb 11, 2005 8:17 pm


-----------------------------------
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
Sat Feb 12, 2005 12:28 am


-----------------------------------
to give them values you would do something like:
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) %