[Help] Yet Again, proc and Loops, and loops in loops
Author |
Message |
razrdude
|
Posted: Mon Oct 30, 2006 6:05 pm Post subject: [Help] Yet Again, proc and Loops, and loops in loops |
|
|
Hey well whoever's been following my posts, Ive now added ship movements and have the ship moving around, but now the problem is that the scope is being drawn once only and its not moving with the mouse. I know its cuz of the cls and View Image but I do not know how to fix it. Ill post my code here, but its better if you dl the file cuz there are images. Thanks a lot for all help.
btw I have to do these:
1. Get scope to show and moving
2. Collision Detection, ship gets blasted
3. Ship spawn
4. Parameters maybe.
5. Instructions and Documentation
code: | %The GUI contains the predefined subprograms for creating & using a Graphical
%User Interface
import GUI
%Setcreen creates a window, enters graphic mode, changes the window to 1000
%x600 and turns of the cursor
setscreen ("graphics:1000;600,nocursor")
%This variable is an integers and allow the scope to be drawn anywhere
var x, y, button : int
var mspace1 : int
var spaceship : int
spaceship := Pic.FileNew ("shipf.bmp")
var spacex, spacey : int
var background : int
background := Pic.FileNew ("background.bmp")
spacex := 450
spacey := 300
% this loop is used to randomly generate direction of movement for the space ship
procedure draw (x, y : int)
View.Set ("offscreenonly")
loop
randint (mspace1, 1, 4)
if mspace1 = 1 then
spacey := (spacey + 50)
else
if mspace1 = 2 then
spacex := (spacex - 50)
else
if mspace1 = 3 then
spacey := (spacey - 50)
else
if mspace1 = 4 then
spacex := (spacex + 50)
end if
end if
end if
end if
Pic.Draw (spaceship, spacex, spacey, picUnderMerge)
delay (300)
View.Update
cls
Pic.Draw (background, 0, 0, picUnderMerge)
%Scope casting
Draw.FillOval (x, y, 55, 55, black)
Draw.FillOval (x, y, 50, 50, white)
%Thick crosshair threads
Draw.ThickLine (x - 50, y, x - 35, y, 3, black)
Draw.ThickLine (x + 50, y, x + 35, y, 3, black)
Draw.ThickLine (x, y - 50, x, y - 35, 3, black)
Draw.ThickLine (x, y + 50, x, y + 35, 3, black)
%Thin threads
Draw.Line (x - 20, y, x + 20, y, red)
Draw.Line (x, y - 20, x, y + 20, red)
end loop % this ends the loop of movement
end draw
loop
Mouse.Where (x, y, button)
draw (x, y)
end loop
|
If you want to test to see if the scope is being made, put ur mouse on the middle of the screen and press F1 (run).
Thanks
Description: |
|
![](http://compsci.ca/v3/pafiledb/images/icons/clip.gif) Download |
Filename: |
Final Project - 6.rar |
Filesize: |
12.12 KB |
Downloaded: |
70 Time(s) |
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Piro24
|
Posted: Mon Oct 30, 2006 8:54 pm Post subject: (No subject) |
|
|
I'm a noob in Turing too (started about 3-4 weeks ago), but...
What's the point in making your entire code a procedure?
If you are going to do it all in one loop, don't use a procedure...That way the Mouse.Where will apply to your scope...
|
|
|
|
|
![](images/spacer.gif) |
razrdude
|
Posted: Mon Oct 30, 2006 9:01 pm Post subject: (No subject) |
|
|
Yea i got a fix from Ultrahex [All hail Ultrahex]
code: | %User Interface
import GUI
%Setcreen creates a window, enters graphic mode, changes the window to 1000
%x600 and turns of the cursor
setscreen ("graphics:1000;600,nocursor")
%This variable is an integers and allow the scope to be drawn anywhere
var x, y, button : int
var mspace1 : int
var spaceship : int
spaceship := Pic.FileNew ("shipf.bmp")
var spacex, spacey : int
var background : int
background := Pic.FileNew ("background.bmp")
spacex := 450
spacey := 300
% this loop is used to randomly generate direction of movement for the space ship
procedure draw (x, y : int)
View.Set ("offscreenonly")
randint (mspace1, 1, 10)
if mspace1 = 1 then
spacey := (spacey + 50)
else
if mspace1 = 2 then
spacex := (spacex - 50)
else
if mspace1 = 3 then
spacey := (spacey - 50)
else
if mspace1 = 4 then
spacex := (spacex + 50)
end if
end if
end if
end if
Pic.Draw (spaceship, spacex, spacey, picUnderMerge)
%delay (300)
Pic.Draw (background, 0, 0, picUnderMerge)
%Scope casting
Draw.FillOval (x, y, 55, 55, black)
Draw.FillOval (x, y, 50, 50, white)
%Thick crosshair threads
Draw.ThickLine (x - 50, y, x - 35, y, 3, black)
Draw.ThickLine (x + 50, y, x + 35, y, 3, black)
Draw.ThickLine (x, y - 50, x, y - 35, 3, black)
Draw.ThickLine (x, y + 50, x, y + 35, 3, black)
%Thin threads
Draw.Line (x - 20, y, x + 20, y, red)
Draw.Line (x, y - 20, x, y + 20, red)
delay (20)
View.Update
cls
end draw
loop
Mouse.Where (x, y, button)
draw (x, y)
end loop
|
but now the scope appears on top of the spaceship, how do i fix that?
Also need help with collision detection.
|
|
|
|
|
![](images/spacer.gif) |
Expirant
|
Posted: Mon Oct 30, 2006 11:10 pm Post subject: (No subject) |
|
|
To get the spaceship to appear beneath the crosshair you need to draw the spaceship over the crosshair.
I'm not really sure what picUnderMerge does exactly...but it looks like it moves that particular picture to the back?
Anyways, moving your drawing of the spaceship to the end of your code (so...drawing it last) should fix it. I would separate your code into a more organized fashion, though, to give you more flexibility with it.
Good luck,
Expirant
|
|
|
|
|
![](images/spacer.gif) |
razrdude
|
Posted: Tue Oct 31, 2006 12:58 am Post subject: (No subject) |
|
|
Hey people here is what i have so far. The only problem is that Now I need the mouse to click in a specific range to make the health go down.
code: | %User Interface
import GUI
%Setcreen creates a window, enters graphic mode, changes the window to 1000
%x600 and turns of the cursor
setscreen ("graphics:1000;600,nocursor")
%This variable is an integers and allow the scope to be drawn anywhere
var x, y, button : int
var mspace1 : int
var i : int
var spaceship : int
spaceship := Pic.FileNew ("ship.bmp")
var background : int
background := Pic.FileNew ("background.bmp")
var explosion : int
explosion := Pic.FileNew ("explosion.bmp")
var health1 : int
health1 := Pic.FileNew ("health1.bmp")
var health2 : int
health2 := Pic.FileNew ("health2.bmp")
var health3 : int
health3 := Pic.FileNew ("health3.bmp")
var health4 : int
health4 := Pic.FileNew ("health4.bmp")
var health5 : int
health5 := Pic.FileNew ("health5.bmp")
var health6 : int
health6 := Pic.FileNew ("health6.bmp")
var health7 : int
health7 := Pic.FileNew ("health7.bmp")
var health8 : int
health8 := Pic.FileNew ("health8.bmp")
var health9 : int
health9 := Pic.FileNew ("health9.bmp")
var health10 : int
health10 := Pic.FileNew ("health10.bmp")
var health11 : int
health11 := Pic.FileNew ("health11.bmp")
var health12 : int
health12 := Pic.FileNew ("health12.bmp")
var health13 : int
health13 := Pic.FileNew ("health13.bmp")
var health14 : int
health14 := Pic.FileNew ("health14.bmp")
var health15 : int
health15 := Pic.FileNew ("health15.bmp")
var health16 : int
health16 := Pic.FileNew ("health16.bmp")
var health17 : int
health17 := Pic.FileNew ("health17.bmp")
var health18 : int
health18 := Pic.FileNew ("health18.bmp")
var health19 : int
health19 := Pic.FileNew ("health19.bmp")
var health20 : int
health20 := Pic.FileNew ("health20.bmp")
var health21 : int
health21 := Pic.FileNew ("health21.bmp")
var pos : int
var spacex, spacey : int
spacex := 450
spacey := 300
i := 1
% this loop is used to randomly generate direction of movement for the space ship
procedure draw (x, y : int)
View.Set ("offscreenonly")
randint (mspace1, 1, 15)
if mspace1 = 1 then
spacey := (spacey + 30)
else
if mspace1 = 2 then
spacex := (spacex - 30)
else
if mspace1 = 3 then
spacey := (spacey - 30)
else
if mspace1 = 4 then
spacex := (spacex + 30)
end if
end if
end if
end if
Pic.Draw (spaceship, spacex, spacey, picXor)
%Pic.Draw (health1, 190, 525, picMerge)
Pic.Draw (background, 0, 0, picMerge)
%health counter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%something over here%%%%%%%%%%%%%%%%%%%%%%%%
if x=spacex+-500 and y=spacey+-500 and button=1 then
i := i + 1
end if
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if i = 1 then
Pic.Draw (health1, 190, 525, picMerge)
else
if i = 2 then
Pic.Draw (health2, 190, 525, picMerge)
else
if i = 3 then
Pic.Draw (health3, 190, 525, picMerge)
else
if i = 4 then
Pic.Draw (health4, 190, 525, picMerge)
else
if i = 5 then
Pic.Draw (health5, 190, 525, picMerge)
else
if i = 6 then
Pic.Draw (health6, 190, 525, picMerge)
else
if i = 7 then
Pic.Draw (health7, 190, 525, picMerge)
else
if i = 8 then
Pic.Draw (health8, 190, 525, picMerge)
else
if i = 9 then
Pic.Draw (health9, 190, 525, picMerge)
else
if i = 10 then
Pic.Draw (health10, 190, 525, picMerge)
else
if i = 11 then
Pic.Draw (health11, 190, 525, picMerge)
else
if i = 12 then
Pic.Draw (health12, 190, 525, picMerge)
else
if i = 13 then
Pic.Draw (health13, 190, 525, picMerge)
else
if i = 14 then
Pic.Draw (health14, 190, 525, picMerge)
else
if i = 15 then
Pic.Draw (health15, 190, 525, picMerge)
else
if i = 16 then
Pic.Draw (health16, 190, 525, picMerge)
else
if i = 17 then
Pic.Draw (health17, 190, 525, picMerge)
else
if i = 18 then
Pic.Draw (health18, 190, 525, picMerge)
else
if i = 19 then
Pic.Draw (health19, 190, 525, picMerge)
else
if i = 20 then
Pic.Draw (health20, 190, 525, picMerge)
else
if i = 21 then
Pic.Draw (health21, 190, 525, picMerge)
Pic.Draw (explosion, 500, 300, picMerge)
if i = 22 then
i := 1
cls
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
%Scope casting
Draw.Oval (x, y, 55, 55, black)
Draw.Oval (x, y, 54, 54, black)
Draw.Oval (x, y, 53, 53, black)
Draw.Oval (x, y, 52, 52, black)
Draw.Oval (x, y, 51, 51, black)
Draw.Oval (x, y, 50, 50, black)
Draw.Oval (x, y, 54, 54, black)
Draw.Oval (x, y, 54, 53, black)
Draw.Oval (x, y, 54, 52, black)
Draw.Oval (x, y, 54, 51, black)
Draw.Oval (x, y, 54, 50, black)
Draw.Oval (x, y, 50, 51, black)
Draw.Oval (x, y, 50, 52, black)
Draw.Oval (x, y, 50, 53, black)
Draw.Oval (x, y, 50, 54, black)
Draw.Oval (x, y, 50, 55, black)
Draw.Oval (x, y, 51, 50, black)
Draw.Oval (x, y, 52, 50, black)
Draw.Oval (x, y, 53, 50, black)
Draw.Oval (x, y, 54, 50, black)
Draw.Oval (x, y, 55, 50, black)
%Thick crosshair threads
Draw.ThickLine (x - 50, y, x - 35, y, 3, black)
Draw.ThickLine (x + 50, y, x + 35, y, 3, black)
Draw.ThickLine (x, y - 50, x, y - 35, 3, black)
Draw.ThickLine (x, y + 50, x, y + 35, 3, black)
%Thin threads
Draw.Line (x - 20, y, x + 20, y, red)
Draw.Line (x, y - 20, x, y + 20, red)
delay (20)
View.Update
cls
end draw
loop
Mouse.Where (x, y, button)
draw (x, y)
end loop
% if x=spacex and y=space y and button =1
|
I put a lot of % where the part I am having problems with, to help you find it. Btw pls dont flame for the way I did this code, I am running out of time and couldnt do it the short way. All Help is appreciated.
btw if you guys require the whole folder i can attach it on my next post
|
|
|
|
|
![](images/spacer.gif) |
[Gandalf]
![](http://compsci.ca/v3/uploads/user_avatars/189297994e4c716fec7f1.png)
|
Posted: Tue Oct 31, 2006 3:20 am Post subject: (No subject) |
|
|
First off, you'll want to replace all these:
with the proper elsif structue:
Then, read through my PM, if this is the topic you were referring to.
|
|
|
|
|
![](images/spacer.gif) |
razrdude
|
Posted: Tue Oct 31, 2006 3:49 am Post subject: (No subject) |
|
|
ok I did that but still having problem with getting the ship to stop drawing and moving, cuz on the 22nd click the explosion picture goes away and the ship keeps on moving.
Here is the updated code:
code: |
%User Interface
import GUI
%Setcreen creates a window, enters graphic mode, changes the window to 1000
%x600 and turns of the cursor
setscreen ("graphics:1000;600,nocursor")
process music
Music.PlayFile ("sound.mp3")
end music
fork music
%This variable is an integers and allow the scope to be drawn anywhere
var x, y, button : int
var mspace1 : int
var i : int
var pos : int
var spacex, spacey : int
var spaceship : int
spaceship := Pic.FileNew ("ship.bmp")
var background : int
background := Pic.FileNew ("background.bmp")
var explosion : int
explosion := Pic.FileNew ("explosion.bmp")
var health1 : int
health1 := Pic.FileNew ("health1.bmp")
var health2 : int
health2 := Pic.FileNew ("health2.bmp")
var health3 : int
health3 := Pic.FileNew ("health3.bmp")
var health4 : int
health4 := Pic.FileNew ("health4.bmp")
var health5 : int
health5 := Pic.FileNew ("health5.bmp")
var health6 : int
health6 := Pic.FileNew ("health6.bmp")
var health7 : int
health7 := Pic.FileNew ("health7.bmp")
var health8 : int
health8 := Pic.FileNew ("health8.bmp")
var health9 : int
health9 := Pic.FileNew ("health9.bmp")
var health10 : int
health10 := Pic.FileNew ("health10.bmp")
var health11 : int
health11 := Pic.FileNew ("health11.bmp")
var health12 : int
health12 := Pic.FileNew ("health12.bmp")
var health13 : int
health13 := Pic.FileNew ("health13.bmp")
var health14 : int
health14 := Pic.FileNew ("health14.bmp")
var health15 : int
health15 := Pic.FileNew ("health15.bmp")
var health16 : int
health16 := Pic.FileNew ("health16.bmp")
var health17 : int
health17 := Pic.FileNew ("health17.bmp")
var health18 : int
health18 := Pic.FileNew ("health18.bmp")
var health19 : int
health19 := Pic.FileNew ("health19.bmp")
var health20 : int
health20 := Pic.FileNew ("health20.bmp")
var health21 : int
health21 := Pic.FileNew ("health21.bmp")
spacex := 450
spacey := 300
i := 1
% this loop is used to randomly generate direction of movement for the space ship
procedure draw (x, y : int)
View.Set ("offscreenonly")
randint (mspace1, 1, 6)
if mspace1 = 1 then
spacey := (spacey + 60)
else
if mspace1 = 2 then
spacex := (spacex - 60)
else
if mspace1 = 3 then
spacey := (spacey - 60)
else
if mspace1 = 4 then
spacex := (spacex + 60)
end if
end if
end if
end if
Pic.Draw (spaceship, spacex, spacey, picXor)
%Pic.Draw (health1, 190, 525, picMerge)
Pic.Draw (background, 0, 0, picMerge)
%health counter
%loop
% if button :=21
if spacex <= x and spacex <= x and spacey <= x and
spacey <= x and button = 1 then
i := i + 1
end if
%Tbese
if i = 1 then
Pic.Draw (health1, 190, 525, picMerge)
elsif i = 2 then
Pic.Draw (health2, 190, 525, picMerge)
elsif i = 3 then
Pic.Draw (health3, 190, 525, picMerge)
elsif i = 4 then
Pic.Draw (health4, 190, 525, picMerge)
elsif i = 5 then
Pic.Draw (health5, 190, 525, picMerge)
elsif i = 6 then
Pic.Draw (health6, 190, 525, picMerge)
elsif i = 7 then
Pic.Draw (health7, 190, 525, picMerge)
elsif i = 8 then
Pic.Draw (health8, 190, 525, picMerge)
elsif i = 9 then
Pic.Draw (health9, 190, 525, picMerge)
elsif i = 10 then
Pic.Draw (health10, 190, 525, picMerge)
elsif i = 11 then
Pic.Draw (health11, 190, 525, picMerge)
elsif i = 12 then
Pic.Draw (health12, 190, 525, picMerge)
elsif i = 13 then
Pic.Draw (health13, 190, 525, picMerge)
elsif i = 14 then
Pic.Draw (health14, 190, 525, picMerge)
elsif i = 15 then
Pic.Draw (health15, 190, 525, picMerge)
elsif i = 16 then
Pic.Draw (health16, 190, 525, picMerge)
elsif i = 17 then
Pic.Draw (health17, 190, 525, picMerge)
elsif i = 18 then
Pic.Draw (health18, 190, 525, picMerge)
elsif i = 19 then
Pic.Draw (health19, 190, 525, picMerge)
elsif i = 20 then
Pic.Draw (health20, 190, 525, picMerge)
elsif i = 21 then
Pic.Draw (health21, 190, 525, picMerge)
Pic.Draw (explosion, 500, 300, picMerge)
if i = 22 then
i := 1
cls
end if
end if
%Scope casting
Draw.Oval (x, y, 55, 55, black)
Draw.Oval (x, y, 54, 54, black)
Draw.Oval (x, y, 53, 53, black)
Draw.Oval (x, y, 52, 52, black)
Draw.Oval (x, y, 51, 51, black)
Draw.Oval (x, y, 50, 50, black)
Draw.Oval (x, y, 54, 54, black)
Draw.Oval (x, y, 54, 53, black)
Draw.Oval (x, y, 54, 52, black)
Draw.Oval (x, y, 54, 51, black)
Draw.Oval (x, y, 54, 50, black)
Draw.Oval (x, y, 50, 51, black)
Draw.Oval (x, y, 50, 52, black)
Draw.Oval (x, y, 50, 53, black)
Draw.Oval (x, y, 50, 54, black)
Draw.Oval (x, y, 50, 55, black)
Draw.Oval (x, y, 51, 50, black)
Draw.Oval (x, y, 52, 50, black)
Draw.Oval (x, y, 53, 50, black)
Draw.Oval (x, y, 54, 50, black)
Draw.Oval (x, y, 55, 50, black)
%Thick crosshair threads
Draw.ThickLine (x - 50, y, x - 35, y, 3, black)
Draw.ThickLine (x + 50, y, x + 35, y, 3, black)
Draw.ThickLine (x, y - 50, x, y - 35, 3, black)
Draw.ThickLine (x, y + 50, x, y + 35, 3, black)
%Thin threads
Draw.Line (x - 20, y, x + 20, y, red)
Draw.Line (x, y - 20, x, y + 20, red)
delay (20)
View.Update
cls
end draw
loop
Mouse.Where (x, y, button)
draw (x, y)
end loop
% if x=spacex and y=space y and button =1
|
Thanks for all your help
|
|
|
|
|
![](images/spacer.gif) |
Clayton
![](http://compsci.ca/v3/uploads/user_avatars/1718239683472e5c8d7e617.jpg)
|
Posted: Tue Oct 31, 2006 1:24 pm Post subject: (No subject) |
|
|
Things like this break my heart:
Turing: |
if i = 1 then
Pic.Draw (health1, 190, 525, picMerge)
elsif i = 2 then
Pic.Draw (health2, 190, 525, picMerge)
elsif i = 3 then
Pic.Draw (health3, 190, 525, picMerge)
elsif i = 4 then
Pic.Draw (health4, 190, 525, picMerge)
elsif i = 5 then
Pic.Draw (health5, 190, 525, picMerge)
elsif i = 6 then
Pic.Draw (health6, 190, 525, picMerge)
elsif i = 7 then
Pic.Draw (health7, 190, 525, picMerge)
elsif i = 8 then
Pic.Draw (health8, 190, 525, picMerge)
elsif i = 9 then
Pic.Draw (health9, 190, 525, picMerge)
elsif i = 10 then
Pic.Draw (health10, 190, 525, picMerge)
elsif i = 11 then
Pic.Draw (health11, 190, 525, picMerge)
elsif i = 12 then
Pic.Draw (health12, 190, 525, picMerge)
elsif i = 13 then
Pic.Draw (health13, 190, 525, picMerge)
elsif i = 14 then
Pic.Draw (health14, 190, 525, picMerge)
elsif i = 15 then
Pic.Draw (health15, 190, 525, picMerge)
elsif i = 16 then
Pic.Draw (health16, 190, 525, picMerge)
elsif i = 17 then
Pic.Draw (health17, 190, 525, picMerge)
elsif i = 18 then
Pic.Draw (health18, 190, 525, picMerge)
elsif i = 19 then
Pic.Draw (health19, 190, 525, picMerge)
elsif i = 20 then
Pic.Draw (health20, 190, 525, picMerge)
elsif i = 21 then
Pic.Draw (health21, 190, 525, picMerge)
Pic.Draw (explosion, 500, 300, picMerge)
if i = 22 then
i := 1
cls
end if
end if
|
That whole entire if statement can be broken down into:
also, the reason it doesnt work after the 22nd click is this:
code: |
...
elsif i = 21 then
Pic.Draw(explosion,...)
if i = 22 then
i := 1
end if
end if
|
because i will never equal 21 and 22 at the same time, you will never get the required results. Put the:
code: |
if i = 22 then
i := 1
end if
|
outside of everything else, and you *should* be fine
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Tue Oct 31, 2006 1:47 pm Post subject: (No subject) |
|
|
Freakman wrote:
That whole entire if statement can be broken down into:
In terms of speed, that's still terrible. Loading the picture from the file is slow. That's why we do that at the beginning of our program. If we wanted to load the picture from file during the execution, we would just use Pic.ScreenLoad.
razrdude, you should really learn to use arrays
|
|
|
|
|
![](images/spacer.gif) |
razrdude
|
Posted: Tue Oct 31, 2006 3:04 pm Post subject: (No subject) |
|
|
Actually the speed is not that bad, btw i tried what Freakman gave and it gave back errors Ok here is what I have now.
Ok Now all I have to do is add in the Boom Sound when the button click is at 21, add in boundaries for the ship, and Im having problems at the bottom calling upon the Draw procedure. Is this because draw has formal parameters?
Please help me on these issues.
code: | %User Interface
import GUI
%Setcreen creates a window, enters graphic mode, changes the window to 1000
%x600 and turns of the cursor
setscreen ("graphics:1000;600,nocursor, title: Space Wars: The Quest of Dri-Falcon")
process music
Music.PlayFile ("sound.mp3")
end music
fork music
process soundexplosion
Music.PlayFile ("explosion.wav")
end soundexplosion
const explosion_sound : string := "explosion.wav"
%These variables are decleared here and are created as integer variables.
var exitif : string
var x, y, button : int
var mspace1 : int
var i : int
var pos : int
var spacex, spacey : int
var font1 : int := Font.New ("Palatino:60:bold")
var font2 : int := Font.New ("Palatino:20:bold")
%These variables are the declarations for the images while Pic.FileNew
%obtains the pictures from the file, (in the same folder)
var spaceship : int
spaceship := Pic.FileNew ("ship.bmp")
var background : int
background := Pic.FileNew ("background.bmp")
var explosion : int
explosion := Pic.FileNew ("explosion2.bmp")
var health1 : int
health1 := Pic.FileNew ("health1.bmp")
var health2 : int
health2 := Pic.FileNew ("health2.bmp")
var health3 : int
health3 := Pic.FileNew ("health3.bmp")
var health4 : int
health4 := Pic.FileNew ("health4.bmp")
var health5 : int
health5 := Pic.FileNew ("health5.bmp")
var health6 : int
health6 := Pic.FileNew ("health6.bmp")
var health7 : int
health7 := Pic.FileNew ("health7.bmp")
var health8 : int
health8 := Pic.FileNew ("health8.bmp")
var health9 : int
health9 := Pic.FileNew ("health9.bmp")
var health10 : int
health10 := Pic.FileNew ("health10.bmp")
var health11 : int
health11 := Pic.FileNew ("health11.bmp")
var health12 : int
health12 := Pic.FileNew ("health12.bmp")
var health13 : int
health13 := Pic.FileNew ("health13.bmp")
var health14 : int
health14 := Pic.FileNew ("health14.bmp")
var health15 : int
health15 := Pic.FileNew ("health15.bmp")
var health16 : int
health16 := Pic.FileNew ("health16.bmp")
var health17 : int
health17 := Pic.FileNew ("health17.bmp")
var health18 : int
health18 := Pic.FileNew ("health18.bmp")
var health19 : int
health19 := Pic.FileNew ("health19.bmp")
var health20 : int
health20 := Pic.FileNew ("health20.bmp")
var health21 : int
health21 := Pic.FileNew ("health21.bmp")
spacex := 450
spacey := 300
i := 1
% this loop is used to randomly generate direction of movement for the space ship
procedure draw (x, y : int)
View.Set ("offscreenonly")
randint (mspace1, 1, 10)
if mspace1 = 1 and i < 21 then
spacey := (spacey + 30)
else
if mspace1 = 2 and i < 21 then
spacex := (spacex - 30)
else
if mspace1 = 3 and i < 21 then
spacey := (spacey - 30)
else
if mspace1 = 4 and i < 21 then
spacex := (spacex + 30)
end if
end if
end if
end if
Pic.Draw (spaceship, spacex, spacey, picXor)
%Pic.Draw (health1, 190, 525, picMerge)
Pic.Draw (background, 0, 0, picMerge)
%health counter
%loop
% if button :=21
if spacex <= x and spacex <= x and spacey <= x and
spacey <= x and button = 1 then
i := i + 1
end if
%Tbese
if i = 1 then
Pic.Draw (health1, 190, 525, picMerge)
elsif i = 2 then
Pic.Draw (health2, 190, 525, picMerge)
elsif i = 3 then
Pic.Draw (health3, 190, 525, picMerge)
elsif i = 4 then
Pic.Draw (health4, 190, 525, picMerge)
elsif i = 5 then
Pic.Draw (health5, 190, 525, picMerge)
elsif i = 6 then
Pic.Draw (health6, 190, 525, picMerge)
elsif i = 7 then
Pic.Draw (health7, 190, 525, picMerge)
elsif i = 8 then
Pic.Draw (health8, 190, 525, picMerge)
elsif i = 9 then
Pic.Draw (health9, 190, 525, picMerge)
elsif i = 10 then
Pic.Draw (health10, 190, 525, picMerge)
elsif i = 11 then
Pic.Draw (health11, 190, 525, picMerge)
elsif i = 12 then
Pic.Draw (health12, 190, 525, picMerge)
elsif i = 13 then
Pic.Draw (health13, 190, 525, picMerge)
elsif i = 14 then
Pic.Draw (health14, 190, 525, picMerge)
elsif i = 15 then
Pic.Draw (health15, 190, 525, picMerge)
elsif i = 16 then
Pic.Draw (health16, 190, 525, picMerge)
elsif i = 17 then
Pic.Draw (health17, 190, 525, picMerge)
elsif i = 18 then
Pic.Draw (health18, 190, 525, picMerge)
elsif i = 19 then
Pic.Draw (health19, 190, 525, picMerge)
elsif i = 20 then
Pic.Draw (health20, 190, 525, picMerge)
elsif i >= 21 then
%Pic.Draw (health21, 190, 525, picMerge)
Pic.Draw (explosion, 0, 0, picCopy)
Music.PlayFileStop
fork soundexplosion
Font.Draw ("BOOM! YOU WIN", 175, 500, font1, brightred)
%Font.Draw ("Play Again?", 375, 450, font2, brightred)
%Font.Draw ("Play Again?", 375, 450, font2, brightred)
Font.Draw ("Thank you for playing the game of Space Wars: The Quest of Dri-Falcon", 25, 450, font2, brightred)
Font.Draw ("Please press Ctrl+Alt+Del twice", 275, 400, font2, brightred)
%elsif i = 22 then
% Pic.Draw (health21, 190, 525, picMerge)
%Pic.Free (spaceship)
end if
%if spacx <= x and spacex <= x and spacey <= x and
% spacey <= x and button = 21 then
%Pic.FrPic.Draw (explosion, 500, 300, picMerge)e (spaceship)
%Scope end ifcasting
Draw.Oval (x, y, 55, 55, black)
Draw.Oval (x, y, 54, 54, black)
Draw.Oval (x, y, 53, 53, black)
Draw.Oval (x, y, 52, 52, black)
Draw.Oval (x, y, 51, 51, black)
Draw.Oval (x, y, 50, 50, black)
Draw.Oval (x, y, 54, 54, black)
Draw.Oval (x, y, 54, 53, black)
Draw.Oval (x, y, 54, 52, black)
Draw.Oval (x, y, 54, 51, black)
Draw.Oval (x, y, 54, 50, black)
Draw.Oval (x, y, 50, 51, black)
Draw.Oval (x, y, 50, 52, black)
Draw.Oval (x, y, 50, 53, black)
Draw.Oval (x, y, 50, 54, black)
Draw.Oval (x, y, 50, 55, black)
Draw.Oval (x, y, 51, 50, black)
Draw.Oval (x, y, 52, 50, black)
Draw.Oval (x, y, 53, 50, black)
Draw.Oval (x, y, 54, 50, black)
Draw.Oval (x, y, 55, 50, black)
%Thick crosshair threads
Draw.ThickLine (x - 50, y, x - 35, y, 3, black)
Draw.ThickLine (x + 50, y, x + 35, y, 3, black)
Draw.ThickLine (x, y - 50, x, y - 35, 3, black)
Draw.ThickLine (x, y + 50, x, y + 35, 3, black)
%Thin threads
Draw.Line (x - 20, y, x + 20, y, red)
Draw.Line (x, y - 20, x, y + 20, red)
delay (20)
View.Update
cls
end draw
loop
Mouse.Where (x, y, button)
draw (x, y)
end loop
% if x=spacex and y=space y and button =1
procedure instructions
Text.Color (red)
put "Hello User, You are stuck on Planet K420 Cosmos and you have to kill all",
skip
put "the aliens to save planet earth. Move around the mouse to aim and then bLAST THEM FOOLS!!"
end instructions
%var button1:int:=GUI.CreateButton(20,20,100,"START", draw)
var button2 : int := GUI.CreateButton (200, 20, 100, "INSTRUCTIONS", instructions)
loop
exit when GUI.ProcessEvent
end loop
var winID : int := Window.Open ("position:center,center;graphics:1000;600;offscreenonly")
|
|
|
|
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Tue Oct 31, 2006 4:47 pm Post subject: (No subject) |
|
|
razrdude wrote: Actually the speed is not that bad, btw i tried what Freakman gave and it gave back errors Ok here is what I have now.
Relative to what the speed should be, I can just about guarentee your speed is terrible.
You should really go learn arrays. Now. It will help you so much.
|
|
|
|
|
![](images/spacer.gif) |
|
|