
-----------------------------------
MyPistolsIn3D
Sat May 01, 2004 4:40 pm

erasing picture
-----------------------------------
Ok, I want to erase the picture thats drawn when its hit by bullet fire in my game, but there is multiple pictures on the screen all in one array. how do I do it?


type planes :
    record
        x : int
        y : int
    end record
var planey : array 1 .. 10 of planes

for i : 1 .. 10
    planey (i).x := Rand.Int (0, maxx)
    planey (i).y := Rand.Int (maxy, maxy + 800)
end for

loop
    Mouse.Where (x, y, button)
    plane -> Move (x - 50, y - 60)
    for i : 1 .. 10
        planey (i).y -= 2
        Pic.Draw (picID2, planey (i).x, planey (i).y, picMerge) %PICTURE
    end for
    if button = 1 then
        fork gunfire
    end if
    View.Update
end loop[/code]

-----------------------------------
Delos
Sat May 01, 2004 4:52 pm


-----------------------------------
You could:

- have a boolean operator that decides whether the pic is drawn or not - once hit by the fire, it turns off (false), thus in your next redrawing of the screen, the pic is omitted

- draw the bg over it.  If you have a single colour, cls could work

- if you have a limited number of colours being used, PicXOR could work...

-----------------------------------
MyPistolsIn3D
Sat May 01, 2004 5:22 pm


-----------------------------------
yea, I've tried doing all those but I cant incorporate it into the array right...

-----------------------------------
Tony
Sat May 01, 2004 5:28 pm


-----------------------------------
you could keep images in a flexable array, and when you want to delete an image, you swap image to be deleted with the last element, then resize array down one point, effectivly eliminating the image.

though you'd have to run your forloops using Upper(arrayName) so you dont get out of range error

-----------------------------------
MyPistolsIn3D
Sat May 01, 2004 5:40 pm


-----------------------------------
Ok, i get what you mean tony, but how would i go about doing that? Could you give me an example or sumthing? thx.

-----------------------------------
Tony
Sat May 01, 2004 8:55 pm


-----------------------------------
sure

var word : flexible array 1 .. 5 of int

put "original array:"

for i : 1 .. upper (word)
    word (i) := Rand.Int (1, 100)
    put word (i)
end for

%removing 3rd element
word (3) := word (upper (word)) %replace 3rd element with last
new word, upper (word) - 1 %drop last element

put "array without 3rd element"
for i : 1 .. upper (word)
    put word (i)
end for


-----------------------------------
MyPistolsIn3D
Sun May 02, 2004 10:42 am


-----------------------------------
thank you very much

-----------------------------------
MyPistolsIn3D
Sun May 02, 2004 5:41 pm


-----------------------------------
:(  I cant get it to work, i've been working on it all day.... any other ideas? or should I do it another way?
