Deleting pictures help
Author |
Message |
kingodoo
|
Posted: Fri Jan 18, 2008 11:10 pm Post subject: Deleting pictures help |
|
|
Okay, well I've run into a slight problem. I started off making a game based around Space Invaders.
The differences : You are a stick man, not a space ship. You shoot a lazer from your head, etc.
Anyhow, I've come to the point where I can make the character fire, but I am unsure as to how to delete the images when they are shot. Here is the code, any help please? P.S. I've quoted out near the bottom "Deleting Enemy Smilies", and have them all set to drawing in other objects, but I'm still unsure. Thanks
% VARIABLES %
import GUI
var picID : int
var x, dx, y := 5
var chars : array char of boolean
var randx, randy : int
randx := Rand.Int (100, 250)
randy := Rand.Int (100, 250)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VARIABLE DICTIONARY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% picID(int) = variable to take picture of the character
% x, dx, y(:=5) = variables for how far left and right, plus the increments of pictures taken
% chars(array char of boolean) = variable for characters on keyboard (movement)
% randx, randy(int) = random x and y integers
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Main Program %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% BACKGROUND %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
View.Set ("graphics:630;350,nobuttonbar,title:Ninja Lazor") % Sets no button bar, the title, and size of screen.
GUI.SetBackgroundColour (blue) % Sets background to blue
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Title Screen %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% CHARACTER %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Draw.FillOval (50, 110, 20, 20, black) % Head
Draw.FillOval (40, 112, 5, 5, brightred) % Left Eye
Draw.FillOval (60, 112, 5, 5, brightred) % Right Eye
Draw.Line (33, 100, 66, 100, brightgreen) % Mouth
Draw.Line (50, 90, 50, 50, black) % Body
Draw.Line (50, 80, 35, 55, black) % Left Arm
Draw.Line (50, 80, 65, 55, black) % Right Arm
Draw.Line (50, 50, 35, 25, black) % Left Leg
Draw.Line (50, 50, 65, 25, black) % Right Leg
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Enemy Smileys %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Top Row %
Draw.FillOval (510, 320, 15, 15, yellow) % Far Right %
Draw.FillOval (430, 320, 15, 15, yellow)
Draw.FillOval (350, 320, 15, 15, yellow)
Draw.FillOval (270, 320, 15, 15, yellow)
Draw.FillOval (190, 320, 15, 15, yellow)
Draw.FillOval (110, 320, 15, 15, yellow)
Draw.FillOval (30, 320, 15, 15, yellow) % Far Left %
%***************************************
%************* Bottom Row *************
Draw.FillOval (470, 270, 15, 15, yellow) % Far Right %
Draw.FillOval (390, 270, 15, 15, yellow)
Draw.FillOval (310, 270, 15, 15, yellow)
Draw.FillOval (230, 270, 15, 15, yellow)
Draw.FillOval (150, 270, 15, 15, yellow)
Draw.FillOval (70, 270, 15, 15, yellow) % Far Left
%***************************************
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Movement and Bounderies %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
picID := Pic.New (0, 0, 200, 150) % Declares picID
Pic.Draw (picID, 0, 0, picMerge) % Re-draws the picture and merges it with background
loop % Loop to keep on repeating the movement process
Pic.Draw (picID, x, y, picCopy) % Copies the picture of the stick man %
delay (50) % Delays the time at which he moves %
Pic.Draw (picID, x, y, picMerge) % Merges the picture with the background %
% Movement with Arrows (Left and Right) %
Input.KeyDown (chars)
if chars (KEY_RIGHT_ARROW) and x < maxx - 170 then % if right arrow is pressed, then x value becomes positive
x := x + dx
end if
if chars (KEY_LEFT_ARROW) and x >= -15 then % if left arrow is pressed, then x value becomes negative
x := x - dx
end if
if chars (KEY_ENTER) then % If enter is pressed, then a green line will be drawn from the characters head.
Draw.Line (x + 50, y + 130, x + 50, 330, brightgreen)
delay (200) % time delay before erasing
Draw.Line (x + 50, y + 70, x + 50, 360, blue) % Draws a blue line over the green line (erases)
end if
end loop % Stops the loop for movement
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Deleting Enemy Smileys %
% Top Row *******************************
%
% Draw.FillOval (576, 320, 15, 15, blue)
% Draw.FillOval (526, 320, 15, 15, blue)
% Draw.FillOval (476, 320, 15, 15, blue)
% Draw.FillOval (426, 320, 15, 15, blue)
% Draw.FillOval (376, 320, 15, 15, blue)
% Draw.FillOval (326, 320, 15, 15, blue)
% Draw.FillOval (276, 320, 15, 15, blue)
% Draw.FillOval (226, 320, 15, 15, blue)
% Draw.FillOval (176, 320, 15, 15, blue)
% Draw.FillOval (126, 320, 15, 15, blue)
% Draw.FillOval (76, 320, 15, 15, blue)
% ***************************************
%
% ************* Bottom Row *************
%
% Draw.FillOval (550, 270, 15, 15, blue)
% Draw.FillOval (500, 270, 15, 15, blue)
% Draw.FillOval (450, 270, 15, 15, blue)
% Draw.FillOval (400, 270, 15, 15, blue)
% Draw.FillOval (350, 270, 15, 15, blue)
% Draw.FillOval (300, 270, 15, 15, blue)
% Draw.FillOval (250, 270, 15, 15, blue)
% Draw.FillOval (200, 270, 15, 15, blue)
% Draw.FillOval (150, 270, 15, 15, blue)
% Draw.FillOval (100, 270, 15, 15, blue)
% Draw.FillOval (50, 270, 15, 15, blue)
% ***************************************
loop
exit when GUI.ProcessEvent
end loop |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
TokenHerbz
![](http://compsci.ca/v3/uploads/user_avatars/717170395558e628d9452b.jpg)
|
Posted: Sat Jan 19, 2008 11:52 am Post subject: RE:Deleting pictures help |
|
|
If you've used to Pic. to create a picture which is the one you want to remove, use Pic.Free(PicID). This tells turing to release the memory used to store that picture ID. However if its something to do with GUI, i have no idea, i don't use that horrid thing. |
|
|
|
|
![](images/spacer.gif) |
kingodoo
|
Posted: Sat Jan 19, 2008 3:20 pm Post subject: Re: Deleting pictures help |
|
|
aw okay Thanks anyways though ![Smile Smile](images/smiles/icon_smile.gif) |
|
|
|
|
![](images/spacer.gif) |
|
|