Beginners Community Project - Space Invaders

Blitz3D Forums/Blitz3D Beginners Area/Beginners Community Project - Space Invaders

SoggyP(Posted 2005) [#1]
*** Please could a moderator make this sticky ***

Below is the skeleton code for a space invaders clone that I am giving to the Blitz Beginners Community as a starting point for development. It's completely self-contained and fairly self-explanatory - I'll comment it soon, promise.

The idea here is three-fold:
1) That people can see how certain things are done(eg, there are very basic particle and parallax effects);
2) That the Blitz Community can develop it into a complete game, ie, give it intro screens, player lives, level, etc, so that others can use it to learn how to make a complete game;
3) Finally, that reusable community code is developed so that people don't have to reinvent the wheel every time they want a high-score table, etc.

One final caveat - all code developed remains completely public domain meaning that you're not allowed to make claims on any code provided(the same goes for me too). It's meant as a development mechanism for everyone - everyone is free to contribute and everyone is free to take what they want(giving credits where due). The idea is not to make money from this, it's to enable people to learn how to program(and then make money).

Any comments welcome.

UPDATED 18/NOV/2005

Now in place are Riverratts graphics.
Also in place are Becky Roses sound functions - anyone want to add extra sounds, that'd be groovy (for alien shots and alien, player and mothership explosions)

I've added:
A high score table
Levels
Lives and extra lives
Intro screen, level screen and game over screen.
Bonuses - Really exciting :0)
Anything else needed?




wizzlefish(Posted 2005) [#2]
Yay! I support you 518.9014%!

Community projects are really motivating! Keep it up!


Erroneouss(Posted 2005) [#3]
I love the flashing screen when you get hurt!
I hope this helps some newer coders.


wizzlefish(Posted 2005) [#4]
WHOA!!!

Really really fast!


wizzlefish(Posted 2005) [#5]
I also like the idea that it has no media - it would be really cool if you released a really neat game that needed no media. The game download would only be half a meg!


RiverRatt(Posted 2005) [#6]
Thats one fast game!
Verry good, and nice code too.


RiverRatt(Posted 2005) [#7]
I added some space ships I coded a while back.




SoggyP(Posted 2005) [#8]
Greetings Puppies,

Well sweet, thanks, though you might want to reduce the size of the mothership ;0).

Peace,

Jes


wizzlefish(Posted 2005) [#9]
Man - it's amazing what you can do with no media! Those actually look like bitmaps!


grindalf(Posted 2005) [#10]
i think that its a great idea and have contributed a small no media arkanoid clone, i doubt it will be very usefull butt if anyone wants to use it be my guest.

i removed the code due to its impracticality, and that about half of it was missing. see below where i have posted the improved code sorry about the messs


Rob Farley(Posted 2005) [#11]
Grindalf, please try not to take offence at this, however, I'm sure you will, so sorry... but that code is very very ugly and really should be used as an example of how not to do it. Although I've only skimmed your code:

You should never never have

.loop
stuff
goto loop

Bad Bad Bad

The amount of repeated code on you if p1hp>0 stuff should be a function.

Your multiple variable p1hp p2hp etc could be an array and you repeated if statements could be reduced to a loop and a single if statement.

I'm not going to go into it further, but it's full of very bad coding practice.

Again, sorry if I've caused offence.


grindalf(Posted 2005) [#12]
thanks, maybe when i paste in my missing code tommorow you could redo it better and show me how its done. i've never been fully sure of how to use arays.


wizzlefish(Posted 2005) [#13]
I couldn't run it - too many errors.


grindalf(Posted 2005) [#14]
sorry about the mess up there i've deleted it now. i think this might be better i've looked into types, tell me what you think.




SoggyP(Posted 2005) [#15]
Greetings Puppies,

From a quick glance it looks better. I'll have a proper play next week after my exams are over.

Peace,

Jes


wizzlefish(Posted 2005) [#16]
I really like that game!

It's addictive and fun!


RiverRatt(Posted 2005) [#17]
The game it's self is ok. I like the power-up thing.

But if you want to improve it...
The code is very hard to read.
Part of the reason is the way you define variables.
Look at this line
( If npower<1 Then npower=power:ppy=pwy:ppx=pwx )

I can tell what npower is and power but ppy,pwy,ect...?
In short, use full words. Your variables should give some idea of what they do. If you get into big programs you will see the value of this.

Next, correct me if I'm wrong, but I can't find where you are deleting the pill types when hit.

I don't know if you had it indented before posting it here but in case you didn't, You should learn to indent your code. It makes is way easier to read.

In your collision test you have...
 If pills\hp=1 And x2+20>pills\px+2 And x2<pills\px+98 And y2+20>pills\py And y2<pills\py+30 Then ysp=ysp-ysp*2:pills\hp=0:power=Rand(-5,1)pwx=x2:pwy=y2:points=points+1


I think you should look at using images overlap
if imagesoverlap ball,pill then...


Well thats all I'll say for now. I'm just passing on advice others have given me.


grindalf(Posted 2005) [#18]
but correct me if im wrong but imagesoverlap only works with loadimage(media), and i deliberetly made this without so the imageoverlap wouldent work would it.?

oh and sorry about it being confusing. i'll try and put more remarks and better named variables next time.


WolRon(Posted 2005) [#19]
ImagesOverlap (image1,x1,y1,image2,x2,y2)

No where in there does it say that the image has to be loaded with LoadImage.

Instead of executing all of your drawing code every frame, you could have (should have) created some images using the CreateImage command and just drew to them one time. This would then allow you to use the ImagesOverlap or ImagesCollide commands.


SoggyP(Posted 2005) [#20]
Greetings Puppies,

Had a look at the game and it plays sweetly, but what Wolron says it right. If you look at the code for the space invaders above, especially the CreateImage() & 'SetBuffer ImageBuffer()' line, you'll see that you can create images in code that exhibit the same behaviour as loaded media.

As I said, I'll take a good look next week and open another topic with an updated version of this.

Peace,

Jes


grindalf(Posted 2005) [#21]
thanks for the input, your comments have made made my programing easyer better and less space consuming(my original code for that game was 800+lines).


wizzlefish(Posted 2005) [#22]
I have a little program that may teach beginners more things about 3D. It's a 3D program called SpinShooter - it's a real beginner program. I made it cause I was bored.

View here.


Ross C(Posted 2005) [#23]
grindalf, you should try and tab you code, when it comes to functions or loops or if's. So, your code would become:



Looks alot neater, and you can tell the beginning and end of loops, and if's and such. :o)


wizzlefish(Posted 2005) [#24]
This community project isn't getting anywhere.


SoggyP(Posted 2005) [#25]
Greetings Puppies,

I finish my exams today so I'll be able to concentrate on it a little more.

Peace,

Jes


SoggyP(Posted 2005) [#26]
Greetings Puppies,

Here is some updated code. The program is 'complete', ie, it has multiple levels, lives, extra lives, scoring, a high score table, an intro screen, a level indicator, etc. All of the above work, though they're not necessarily the best way forward.

If anyone would like to contribute, please feel free.



Peace,

Jes


RiverRatt(Posted 2005) [#27]
This game is looking good. I might have some things to contribute.


Ross C(Posted 2005) [#28]
No Enemies: No point saying the project isn't getting anywhere. If you concerned, you can contribute to it.


wizzlefish(Posted 2005) [#29]
I made a contribution.

And I think we should also start teaching them 3D games, such as my simple SpinShooter. Because 3D is what most people are interested in.


SoggyP(Posted 2005) [#30]
Greetings Puppies,

If people want to contribute to this * 2d Space Invaders * project, then great. If you want to start threads of your own about 3d then that is also great. If most people want to do 3d, then that is great.

If you're not going to add code or contributive criticism, please can you not post here.

@RiverRatt: As you can see my presentation skills aren't particularly good (but that wasn't really the point). You've obviously got an artistic eye and if you want to improve any of the eye-candy, then that would be most welcome.

Peace,

Jes


Alienforce(Posted 2005) [#31]
No Enemies: Good idea! Your code for SpinShooter would be a good beginner 3d spinoff because most of the "beginner" codes floating around are mostly some FPS code.
And a good game is more about the basic idea.

/Alienforce

PS. PacMan is a game idea i like :)


RiverRatt(Posted 2005) [#32]
I know that was not the point. The point is to make a game that is

"1) That people can see how certain things are done(eg, there are very basic particle and parallax effects);
2) That the Blitz Community can develop it into a complete game, ie, give it intro screens, player lives, level, etc, so that others can use it to learn how to make a complete game;
3) Finally, that reusable community code is developed so that people don't have to reinvent the wheel every time they want a high-score table, etc."

My interest here is in number 3. We can then show that by making reusible code that the same code can be used in 2d or 3d. And when this (2d) prodject is complete I will prove it.
As for the graphics I can supply a little editer I made for that, but that can wait till last don,t you think.


SoggyP(Posted 2005) [#33]
Greetings Puppies,

Of course, that'd be good. What else does this need (apart from commenting) - sound, I suppose is the obvious choice - but what else can we do with space invaders?

Peace,

Jes


RiverRatt(Posted 2005) [#34]
First I think start rewriting the functions into self contained functions that don't need globals or any variables
asigned outside the functions. You know something like
badguy=get_image(badguy,badguy\x,badguy\y,badguy\height,badguy\width)


And for some general game Ideas...
The ufo at the top, when the ufo gets to certain point have iit turn and do a dive bomb at the player.

Or something a little easier, when the ufo is hit break it up into a bunch of little ships that dive at the player. That would be easy just replace some of the paricles whith scaled versions of the ufo and add collisions.

Another Idea is have some of the enemies break off and dive a the player then when it gets to the bottom of the screen it apears at the top and returns to its original position, like the original.

Something else might be powerups and extra lives that float down to the player.
Just some ideas...


wizzlefish(Posted 2005) [#35]
Yay! We're sticky.

I'll contribute any code - I really want to - but just let me know what I need to do. I can't really think of anything - besides using external media...


SoggyP(Posted 2005) [#36]
Greetings Puppies,

@No Enemies : Have a go at RiverRatts second suggestion about turning the ufo particles into dive bombing aliens, that seems a good start, or possibly bonuses, eg, double shots?

Peace,

Jes


RiverRatt(Posted 2005) [#37]
I have started working on an editor of sorts. So far its just a function, that might make it easier to add more ships. You just add a case to the select statment and specify the index number(along with width,height,and scale). It could be used to make all the images in one function.




RiverRatt(Posted 2005) [#38]
Next time I make a dll it will be in a game from scratch. Kind of a pain finding the globals I replaced. Anyhow here is an update of the space invaders. Not much different exept it will be a breeze making new ships and mixing different enimies and other graphics. Tell me what you think
please. It's my first dll, and replaces most of the drawing functions. There are a couple bugs I have to work out but nothing big.

The include with bug fixes


The game



RiverRatt(Posted 2005) [#39]
Wow, that bad aye?


SoggyP(Posted 2005) [#40]
Greetings Puppies,

@RiverRatt: I was in the middle of replying when my wife demanded my attention so you lost out as I got distracted ;0)

The above is an Include, as opposed to a DLL and just separates the graphics creation from the main logic, yeah? That's fine, I'll give it a go later.

I've coded some bonus stuff in which I'll put up later - I think I've put in base rebuilding, extra lives, speed up, cluster bombs and a couple of other things too.

Peace,

Jes


RiverRatt(Posted 2005) [#41]
Uh? I kinda thought a Dll was just another name for an include? Whats the difference?


BlackJumper(Posted 2005) [#42]
A dll is a pre-compiled library that you can use just by knowing how to call the functions 'hidden' inside it (i.e. you never need to see the code.)

An include is just a fancy way of 'cutting and pasting' a big chunk of code into another listing - it gets compiled at the same time as your own code (so you can get a peek at it if you want to... and make changes !)

There are other subtleties, such as shared memory, etc. but the bit above is basically what its all about


RiverRatt(Posted 2005) [#43]
So a dll would be something you would put in the blitz userlib folder?


BlackJumper(Posted 2005) [#44]
Yes... But as long as you know the path to the dll you can really put it anywhere (the .decls file would need to go in userlib. Of course, since you are likely to be using relative paths and putting the dll into the same folder as the main code (when distributing to users) it makes sense to put both the .decls and .dll in the same place.

You cannot create a dll with blitz. Most people around here seem to use PureBasic. Most dll work I have done used Borland Delphi or C++ Builder (just because I know them.) Ironically, in the last project I distributed I forgot to include the Borland Runtime dll and so about half of my testers couldn't use the editor i had supplied to them :-(


SoggyP(Posted 2005) [#45]
Greetings Puppies,

Here is the code as mentioned above. Sorry for the delay but I've been rebuilding my computer.

Is there anything else to do with this?

Peace,

Jes


RiverRatt(Posted 2005) [#46]
I am a little disapointed you do not want to use the code I modified for the include. It would have managed building new levals with different ships and bullet upgrades. But you must have your reasons.


wizzlefish(Posted 2005) [#47]
I'll try to work on some stuff tommorrow. I've been really busy currently. It's coming along great, though!


RiverRatt(Posted 2005) [#48]
No Enemies: Are you working on this? If so what are you going to do? Just asking so don't work on the same thing.


wizzlefish(Posted 2005) [#49]
I want to work on this, but I'm much too busy (coding three games, a forums system, and developing an entire website with the "personality" of BlitzCoder takes up some time), and I was never that great with 2D. If I have the time, I'll work on a small 3D game. I've always wanted to start a community project, or contribute to one, but never found the time. :(


RiverRatt(Posted 2005) [#50]
Well if that's all ya got going on, you should have this done in no time.


RiverRatt(Posted 2005) [#51]
There does not seem to be anyone interested in working on this game.
I have a 3d spaceinvaders type game, 70% done. It just needs some changes here and there. Has a built in particle system, (from JFK), several models (a few that need textures), and a bunch of other things.
Alot of what it needs could be taken from this one.

I will post some sceenshots later, then if
anyones interested I will post the game.


RiverRatt(Posted 2005) [#52]





Crazy4Code(Posted 2005) [#53]
I was just wondering, how do you make that with no media? Is that just shapes blitz shapes?


RiverRatt(Posted 2005) [#54]
This one has media. I'm not <that> good. I also have some mother ships and other stuff made for it, but I have lost intrest so if people want to finish it I'll post the code, but I don't have web space for the models.


Alienforce(Posted 2005) [#55]
Post it RiverRatt, please.

/Alienforce


RiverRatt(Posted 2005) [#56]
Sorry the code is very messy. You will need some models for ships, rocks, and some texutures, and sprites, there is no game timing yet and there is a bug reguarding the explotions but not until you get to the higher levals. No fatal bugs but sometimes the explotions don't show up. I think it is because of the particle system by JFK. It recycles the particles but sometimes more are needed than are available. An easy fix.
I can email the models I guess but they are not that great.




Alienforce(Posted 2005) [#57]
Thanks RiverRatt, I will look at it later on today.

/Alienforce


Banshee(Posted 2005) [#58]
Shooting Sound Added



slenkar(Posted 2005) [#59]
how did you design that sound????


Banshee(Posted 2005) [#60]
Search for the label .makeSound in the code and you'll see it.

All i've done is taken a .wav file and stored it in Data statements, infact I wrote a seperate program to automatically create the Data xxx,xxx... code for me.

I then recreate the sound file in runtime, load it, then remove the file again.

There's probably a better way of doing this by storing the memory section of a loaded .wav file but I couldn't figure out how to do that.


VP(Posted 2005) [#61]
Storing things in banks perhaps? I'm very new to Blitz but a skim of the manual and example code leaves me thinking you can read a datafile into a bank (and therefore can be saved back out again).

Wouldn't be the work of a few minutes to create a little tool that loads all of your datafiles into 1 bank (with some indexing at the end) and then you can save it out as one .dat (or whatever) file.

Not quite as nice as being able to just ditribute one .bb file, but it would scale up to large datasets quite well.


Banshee(Posted 2005) [#62]
Basically yes you can assemble stuff in memory in Blitz relatively easily and construct images and meshes and all sorts from raw data, sound is a bit harder to do than images for reasons I forget now - that's why in the above example I used the data to write a .wav file, loaded it in, then deleted the .wav file - which is a slightly different method.

You can compile your media into your .exe's in this way but unfortunately it will inflate their filesize. There's even tools to do this already in the code archives somewhere. I feel it is better to keep media files seperate so that they can be compressed. Again there are tools which allow you to do this.

If you want to protect your media then the only real solution is to go proprietry, or to swap a few bytes around on your media files that you swap at load time.


VP(Posted 2005) [#63]
Let's face it, most commercially available games have only a moderate amount of protection against ripping their model files, textures, bitmaps, movies and sounds.

If someone really wants a sound from your game, they will get it. For even a leyman hacker, the task will not be impossible. Byte-swapping is fine, until someone just dumps a raw file of the memory areas your task is using - after your game has just 'decrypted' all your resource files.


Yeshu777(Posted 2005) [#64]
Where are we with this project?

Would love to help.


SoggyP(Posted 2005) [#65]
Hello.

The project is as you see it. If there's anything you want to add, feel free. I've not been able to spend much time on Blitz recently but intend getting back to it very soon. Feel free to collate everything and throw it into a codebox and I'll update the first post. It's nice to see that people are still interested in this. I've got a couple of other projects like this that I'm going to put up in the next couple of weeks - centipede, minesweeper and so on.

By the way, Yeshu, if you're interested in having a laugh I'm in a play called 'Ancient Lights' in the Dolman Theatre, Newport from the 14th November. If you're able to come and see it, it's a right cracker of a play with alcohol, dope-smoking, coke-snorting, bestiality, necrophilia, incest, underage sex and so on. Really, it's top.

Goodbye,

Jes


Yeshu777(Posted 2005) [#66]
2 days away! should check this forum more often.

I'll try and come along, work and life permitting - how long does it run for?


SoggyP(Posted 2005) [#67]
Hello.

It runs from the 14th to the 19th, the play starts at 7.15 (7.30 Friday) and I think it's £8 or £5 with concessions.

Hope you can make it.

Goodbye,

Jes


Yeshu777(Posted 2005) [#68]
Will do my best.

My band are looking to play a few venues in Newport, could you suggest any pubs worth approaching.

Bear in mind we play songs from the following bands:

Franz Ferdinand
Hives
Strokes
White Stripes

www.tunakings.tk if you want to see more.

Hopefully see you sometime this week, who do you play?


SoggyP(Posted 2005) [#69]
Hello.

Yeshu, the places you want to approach are:

TJ's - very popular amongst younger people. Lots of comparitively big name bands have played here - Dead Kennedys, Wildhearts, Butthole Surfers, Corrosion of Conformity, etc;
Le Pup - Probably your best bet. Lots of indie bands play here and Sam, the manager, though she can be a bit acerbic at times is very welcoming. They regularly have bands on;
The Riverside - Not as popular as the two places above but still have a good live music reputation;
The Hornblower - More a bikers venue but well renowned for live music and a good crowd. Don't think they'd have any concern with your choice of music.

I play Tom Cavellero, an American movie star who is just past his sell by date. But, boy, what fun he is :o)

Hope the above helps and hope you can make it to the show.

Goodbye.

Jes


Yeshu777(Posted 2005) [#70]
Hi Jes,

Will try and get there tomorrow - playing in Tylerstown Saturday night so thats out.

Thanks for the list of venues, I'll pass it on to our organisor and see if we can get some dates sorted.

Where can I download the source for this project?


SoggyP(Posted 2005) [#71]
Hello.

Ok, Yeshu, I've updated the code in the first post to include Becky's sound code. All you need to do is copy and paste and compile - that's kinda the idea of this. Ok, so with the inclusion of becky's code there is a media file created, but as it's part of the code I think we can live with that.

Hope to see you tonight.

Later,

Jes


big10p(Posted 2005) [#72]
SoggyP: Break a leg and remember not to mention "The Scottish Play"! :)


Trodd(Posted 2005) [#73]
Can I just say that this is a very, very hard version of Invaders!

I am very impressed with how fast the rendering is of the in-built shapes and I love the sound hack!


Buggy(Posted 2006) [#74]
Whoever did the 2D version - you are my hero! Your game with no graphics looks 100 times better than mine with graphics!


Buggy(Posted 2006) [#75]
If this topic isn't being used any more, can you God-like moderators that watch over all with that invisible presence of yours make this un-sticky to clear up the boards?

Thanks for being there like the air. (Hey! A rhyme!)


RiverRatt(Posted 2006) [#76]
This topic is still being used. I have not programed for a while and one day desided to get back into it and desided to work on this. I will be posting what I have done soon.
Hold on a little longer.


RiverRatt(Posted 2006) [#77]
OK. I was going to clean up this code a bit, but decided to post what I have for now. I also want to express some new ideas I have for this game. I have made lot's of changes that might seem odd for a spaceInvaders game. These changes are the basic consepts of the new game play I have in mind. Anyhow, I tried to keep the new functions as portable as posable so they can be used for other games. In fact I bult the Turret and turret select system seperate and then integraded it in. 5 fuction calls make up the Turret secondary bullets that fire anywhere the mouse imige is located, and these functions apear 1 after another in the main game loop like so.


They should stay in that order but can be redistributed through out the main loop. (for example the mouseimage is drawn under the alian ships but needs to be drawn over it. Thats just more work that I was planning to do before posting the code.)

The comments are not all current I need to go through that too, but at the begining I have made coments about ideas I have for the gameplay. Not all will be done of course they are just Ideas. Like the Idea I have for the story line. In short you start out playing space invaders, then you get a mission and the game turns into a scrolling game kind of like zaxon but with mouse control. The goal is to reach the alian warp gates, travel through and destroy them from the other side, amd defeat the alian bosses. So there is three different game plays. Also you get itoms and have an iventory of weopons to use depending on the kind of alians you are fighting. Any how this is what I have done.
Made new enemy ship images, new bullet images, new bullet animations, a turret, a turret select system, the ufo at the top now appears at more random times and will come from iether side of the screen via a 16 image rotation function that will allow it to dive bomb the player, we can now shoot animating bullets, put in some game timeing, added mouse control, added a turret selection system that gives a inventory of turrets that have there own image,mousetarget, and soon will behave different acording to the selected turret. I have done lots of other things too.

There are new controls, Use the mouse right and left buttons to move, the mouse scroll button or numbers 1-3 to equip a different turret. Press c to fire a turret bullet. (Part of the behavior of the bullet I was talking about was different fireing rates, so time limiting has not bin implemented in the turret code yet.) Note: You might need to adjust the frametimer (right before main) to get a suitable frame rate for your computer. If it is still to fast you can slow it down in game useing - or + keys.


RiverRatt(Posted 2006) [#78]
It's rather long now so I have to seperate it into chunks small enough to post. Just cut and paste in the same order they apear.




RiverRatt(Posted 2006) [#79]



RiverRatt(Posted 2006) [#80]



Buggy(Posted 2006) [#81]
In my opinion, it's too hard. My apologies, RiverRatt. I thought no one was working on it any more.


RiverRatt(Posted 2006) [#82]
Do you mean the code is too hard or the gameplay?


Boiled Sweets(Posted 2006) [#83]
Where is the latest downloadable version of this?


RiverRatt(Posted 2006) [#84]
It's 4 posts up in 3 sections cause it's so long. Jus't cut and paste one after another into the blitz editor. The one at the top is what I added to.


Craig H. Nisbet(Posted 2008) [#85]
I can help out with some models. I'm helping out with the Derelict project right now so I won't have time to do anything for a few weeks, but I'll let you know.


Cp(Posted 2008) [#86]
Craig:This is a year old. Nobody is working on it anymore. People have moved onto other things.


Ginger Tea(Posted 2008) [#87]
yet its still sticky ...


Wings(Posted 2008) [#88]
This thread is too long for me to read at 05 am :D

i got a question ?

Is there a space invader with real 3d physics. ?


Blitzplotter(Posted 2008) [#89]
good question wings, a z axis to the guy at the bottom that'd be a challenge.


AJ00200(Posted 2009) [#90]
Isn't Space Invaders the name of the game they show you how to make in 3D Programming For Teens? Thats where I learned BB3D.

AJ00200


RiverRatt(Posted 2009) [#91]
Kill It Then


AJ00200(Posted 2009) [#92]
Inproved the high score menu so it skips to the other side if you are at the edges.
Copy them in the following order:

Gosub makeSound
 TFormFilter 1

Global funct_used

Type Control_Type
	Field Max_Bombs
	Field Bomb_Speed
	Field Crit_Drop_Speed
	Field drop_bomb_chance
	Field Player_StartSpeed
	Field Player_Speed
	;Field Player_index
	Field Bullet_Speed
	Field Max_Rows
	Field Max_Cols
	Field XRes, YRes, Depth
	Field Beast_Speed#
	Field Beast_Speed_Increment#
	Field UFO_Speed
	;+++  direction and index# 
	Field UFO_dir
	Field ufo_index ;index# a referance number in the array that determins what kind of ship to draw
	Field Level
	Field NextExtraLife
End Type

Type points_type
	Field x,y
	Field id
End Type

Type explosion_type
	Field x,y
	Field speed
	Field status
	Field dirx,diry
	Field count
	Field id
End Type

Type HighScoreTable_Type
	Field score
	Field name$
End Type

Dim HighScores.HighScoreTable_type(10)
Global highscore.highscoretable_type
Dim SpaceyFont(40)

Type Player_Type
	Field x,y
	Field moved
	Field lives
	Field score
	Field Shield_Active
	Field Shield_Timer#
	Field Non_Expiring_Shot
	Field NES_Timer# ; Non-expiring shot timer
	Field Cluster
	Field Cluster_Timer#
	Field Speedy
	Field Speedy_Timer#
End Type

Type stars_type
	Field image
	Field x,y
	Field count
End Type

Type Beast_Type
	Field x#,y#
	Field deleted
End Type

Type Bullet_Type
	Field fired
	Field x,y
	Field frame ;+++ keep track of each frame of each animating bullet 
End Type



Type Bomb_Type
	Field fired
	Field x,y
	Field frame	;+++
	Field deleted 
End Type

Type UFO_Type
	Field x,y
	Field status
	
	
	
	
End Type

Type Bonus_Type
	Field active
	Field x,y
	Field frame
	Field frametimer#
End Type
Function Make_lazorcannon_im(lazor_cannon_im)
	SetBuffer ImageBuffer(lazor_cannon_im)
		midx=ImageWidth(lazor_cannon_im)/2
		midy=ImageHeight(lazor_cannon_im)/2
		Color 255,0,0
		Rect midx-10,midy-10,20,20,0	
End Function
;pulsar_cannon_im = CreateImage(20,20)
;Make_pulsarcannon_im(pulsar_cannon_im)
Function Make_pulsarcannon_im(pulsar_cannon_im)
	SetBuffer ImageBuffer(pulsar_cannon_im)
		midx=ImageWidth(pulsar_cannon_im)/2
		midy=ImageHeight(pulsar_cannon_im)/2
		Color 255,255,0
		Rect midx-10,midy-10,20,20,0
End Function
;photon_cannon_im = CreateImage(20,20)
;Make_photoncannon_im(lazor_cannon_im)
Function Make_photoncannon_im(photon_cannon_im)
	SetBuffer ImageBuffer(photon_cannon_im)
		midx=ImageWidth(photon_cannon_im)/2
		midy=ImageHeight(photon_cannon_im)/2
		Color 255,255,255
		Rect midx-10,midy-10,20,20,0
End Function
 









;end of turret set up ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

;*********************************
; Create and Set up Control Type
; This is used to manage all our game control variables,
; it's easier keeping them in one place and putting the set up at the start means we can 
; control the details in the rest of the set up from here on in

Global control.Control_Type
Set_Up_Control

; Set graphics size
Graphics control\xres,control\yres,control\depth
AutoMidHandle True

Dim im(15)
Dim im2(15);IM2____________________IM2_______________________________________________

Dim bases(3)
Dim Points_Ims(16)
Dim debri(16)
Dim stars.stars_type(3)
;+++

;+++ 
Const rots = 16 ;+++ number of rotations for generic rotation function
;Const image_index = 2 ; how many space ships will be able to rotate in the game,ship_type 
;Global image_index

Dim rot_im_array(rots);+++ Dimention the image rotation array
 



Function Make_image_rotate(bitmap)
;the bitmap variable is for any specified image in the function call

	For frame = 0 To rots - 1 
		rot_im_array(frame) = CopyImage(bitmap)
		RotateImage rot_im_array(frame), frame * 360/rots
		DebugLog "rotations "+ frame * 360/rots

		
	Next 
End Function 

; Mouse code starts++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;
;makepoint(mousepoint)
;make the imiges to be used for the hud
mouseimage=CreateImage(20,20)
makemouse(mouseimage)

mousepoint=CreateImage(1,1)
makepoint(mousepoint)
	
Global targetimage=CreateImage(20,20)
maketarget(targetimage)

Global blankimage=CreateImage(23,23)
blanktarget(blankimage)
 
 
Global targetpointimage1=CreateImage(23,23)
maketargetpoint1(targetpointimage1)

Global targetpointimage2=CreateImage(23,23)
maketargetpoint2(targetpointimage2)

Global targetpointimage3=CreateImage(23,23)
maketargetpoint3(targetpointimage3)

Global targetpointimage4=CreateImage(23,23)
maketargetpoint4(targetpointimage4)

Global targetpointimage5=CreateImage(23,23)
maketargetpoint5(targetpointimage5)




 

Global gorightimage=CreateImage(20,20)
goright_im(gorightimage)

Global goleftimage=CreateImage(20,20)
goleft_im(goleftimage)

Global idoltargetimage=CreateImage(20,20)
makeidoltarget(idoltargetimage)



Global player_point=CreateImage(20,20)
SetBuffer ImageBuffer(player_point)
	
	Color 0,0,250
	Line 10,1,1,20
	
	Color 0,0,250
	Line 10,1,20,20
	

	Color 200,0,0
	Line 1,19,20,19


Function makepoint(mousepoint)
	SetBuffer ImageBuffer(mousepoint)
	Color 0,255,0
	Plot 0,0
End Function

Function maketargetpoint1(targetpointimage1)
SetBuffer ImageBuffer(targetpointimage1)
	 	Color 0,55,5
		Oval -1,-1,25,25,False
	
		Color 0,105,5
		Oval -2,-2,27,27,False
	
		Color 0,155,5
		Oval -3,-3,29,29,False
	
		Color 0,205,5
		Oval -4,-4,31,31,False
	
		Color 0,255,5
		Plot 0,0
		Plot 22,0
		Plot 0,22
		Plot 22,22
End Function  		
Function maketargetpoint2(targetpointimage2)
SetBuffer ImageBuffer(targetpointimage2)
		Color 180,180,0
		Oval -1,-1,25,25,False
	
		Color 200,200,10
		Oval -4,-4,31,31,False
	
		Color 255,255,10
		Plot 0,0
		Plot 22,0
		Plot 0,22
		Plot 22,22
	
		Plot 12,12
		Plot 10,10
		Plot 12,10
		Plot 10,12
	
		Color 20,205,10

		Plot 11,11		
End Function 
Function maketargetpoint3(targetpointimage3)
SetBuffer ImageBuffer(targetpointimage3)		
		Color 255,25,225
		Oval -1,-1,25,25,False
	
		Color 240,20,225
		Oval -2,-2,27,27,False
	
		Color 200,25,225
		Oval -3,-3,29,29,False
	
		Color 160,10,225
		Oval -4,-4,31,31,False
	
		Color 120,5,225
		Plot 0,0
		Plot 22,0
		Plot 0,22
		Plot 22,22	    
End Function
Function maketargetpoint4(targetpointimage4)
SetBuffer ImageBuffer(targetpointimage4)		
		Color 255,255,225
		Oval -1,-1,25,25,False
	
		Color 240,205,225
		Oval -2,-2,27,27,False
	
		Color 200,255,225
		Oval -3,-3,29,29,False
	
		Color 160,105,225
		Oval -4,-4,31,31,False
	
		Color 120,55,225
		Plot 0,0
		Plot 22,0
		Plot 0,22
		Plot 22,22	    
End Function 
Function maketargetpoint5(targetpointimage5)
SetBuffer ImageBuffer(targetpointimage5)		
		Color 0,255,225 ;top left blue
		
		Line 0,0,12,12
		
		;Color 0,255,0;top right green

		
		Line 23,0,11,11
		
		;Color 255,0,0;bottomright red

		
		Line 23,23,12,12
		
		;Color 255,0,225 ;bottom left purple

		
		Line 0,23,11,11

		;Color 255,0,225
		;Rect 0, 0, 23, 23,0
		;Rect 12,12,4,4,0
		;Rect 8,8,4,4,0
		;Rect 8,12,4,4,0
		;Rect 12,8,4,4,0
		Color 0,0,0

		Rect 7,7,9,9,1
		

		;Color 255,55,25

		Rect 5,5,13,13,0
		;Rect 4,4,10,10,0
		Rect 2,2,19,19,0

		
	
		Color 255,55,0
		Plot 0,0
		Plot 22,0
		Plot 0,22
		Plot 22,22
		
		

		HandleImage targetpointimage5, ImageWidth(targetpointimage5)/2,ImageHeight(targetpointimage5)/2
		;RotateImage targetpointimage5,45
		;Rect 0, 0, 10, 10,0 	    
End Function 

 

Function makemouse(mouseimage)
	SetBuffer ImageBuffer(mouseimage)
	Color 100,60,250
	Line 0,0,20,10
	Line 0,0,10,20
	Line 20,10,10,20
	
End Function

Function maketarget(targetimage)
	SetBuffer ImageBuffer(targetimage)
	Color 255,20,20
	Line 0,10,20,10
	Line 10,0,10,20

	;Line 0,10,10,20
	;Line 20,110,10,20
	
End Function

Function makeidoltarget(idoltargetimage)
	SetBuffer ImageBuffer(idoltargetimage)
	Color 100,5,50
	Line 5,10,15,10
	Line 10,5,10,15

	;Line 0,10,10,20
	;Line 20,110,10,20
	
End Function

Function blanktarget(blankimage)
	SetBuffer ImageBuffer(blankimage)
	Color 0,0,0
	Rect 0,0,23,23,1
	Color 255,0,0

	Plot 11,11
	;Line 5,10,15,10
	;Line 10,5,10,15

	;Line 0,10,10,20
	;Line 20,110,10,20
	
End Function



Function goleft_im(goleftimage)
	SetBuffer ImageBuffer(goleftimage)
	
	For l=0 To 5
	
		Color 45*l,20*l,255-40*l
		Line 20,10,5+2*l,0+l+l
	
		Line 20,10,5+2*l,19-l-l
	Next 


End Function 

Function goright_im(gorightimage)
SetBuffer ImageBuffer(gorightimage)
	
	
	For l=0 To 5
	Color 45*l,20*l,255-40*l

	
		Line 0,10,15-2*l,0+l+l
	
		Line 0,10,15-2*l,19-l-l
	Next 

End Function
 
;Function drawimages(mouseimage,mousepoint)
Function update_target_point(mouseimage,mousepoint)
	DrawImage mouseimage,MouseX(),MouseY()
	DrawImage mousepoint,MouseX(),MouseY()
End Function

; Mouse code ends++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Global zspeed
Global bim 
Global ufo_im
Global ship_im 
Global bonus_im
Global base_Im

Global bomb_im = CreateImage(20,20,16);BOMB ;BOMB ;BOMB ;BOMB ;BOMB ;BOMB ;BOMB ;BOMB ;BOMB ;BOMB ;BOMB \
Global bomb_im1 = CreateImage(6,24)

Global xp,yp
Global blank_im = CreateImage(6,24)
Global point.points_Type
;bullet code BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
Global bullet_im = CreateImage(6,24)
MidHandle bullet_im
;Global rappedfire_im = CreateImage(6,24,4)
Global rappedfire_im ,rtimer#
Global rframe

rappedfire_im = CreateImage(6,24,16)
Make_rappedfire;+++


Global Quazar_im = CreateImage(20,20,16)

;bullet code ends BBBBBBBBBBBBBBBBBBBBBEEEEEEEEEEEEEBBBBBBBBBBBBBBBEEEEEEEEEEEEEBBBBBBBBBBBBBBBBEEEEEEEE
Global dir# = control\beast_speed
Global score = 0
Global beast_count, total_beasts
Global x#, y#
Global EndGame = False
Global char$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 @#~"
Global adjusttimer = 0
;Global set_master_time$
Global set_master_time

;set_master_time$ = Input ("Master time = ") 
;Write set_master_time$
;set_master_time$=Input$("Please enter a desired frame rate: ") 
;Write "Frame rate set to," + set_master_time$ + "!" 

;set_master_time = (set_master_time$)
set_master_time = 40 
Delay 100

Global frameTimer=CreateTimer(set_master_time); +++ Game timer , Slow it down! 
;Global s

Global explosion.Explosion_type
Global player.Player_Type
Global beast.Beast_Type
Global bullet.bullet_type
Global bombs.bomb_type
Global ufo.ufo_type = New ufo_type
Global Bonus.Bonus_type = New Bonus_type
player.Player_Type = New Player_Type	; create player

Make_Base_Image
Make_Bonus_Images
Make_Collision_Image
Make_Player_Image
Make_Beast_Images
Make_Beast_Images_2 ; +++ a new beast ship for leval two and 3
Make_Beasts
Make_Bases
Make_Points_Ims
Make_Blank

Make_Bombs
Make_Bombs1

Make_Bullets_im
Make_Quazar;+++






;Make_rappedfire;+++
;Make_rappedfire;+++

Make_Debri
Make_Stars
Make_Ship
Make_Ufo_im
Make_Player

Make_Bullet
Make_HighScoreTable
Make_SpaceyFont
;Make_image_rotate(ship_im)
Make_image_rotate(ufo_im)



;*****************************************************************************************************
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Type TBullet
    Field iDir                 ;Holds the direction the Bullet is moving
	Field dX#,dY#              ;Holds the screen x,y coordinates of the bullet
	Field dDistance            ;Holds the counter to see if a bullet has run it's course
	Field dSpeedX#, dSpeedY#   ;Holds the current speed for x and for y
	Field dSpeedModifier#      ;Holds the added speed of the bullet to the current speed
	Field collided			   ;If the bullet collides with an enemy this is set to 1 and that bullet type will be destroyed
	Field frame
	Field equiped
	Field selected 
End Type

Type PTurret_type ;+++
	Field x,y  ;global location on screen to draw the turret relative to the playership image
	Field width ;width in pixels or screen proportions, size of the turret image
	Field height;height in pixels or screen proportions, size of the turret image
	Field frame
	Field ammo ; type of bullet the turret shoots 
	Field equiped
	Field iDir 
	Field selected ;The currently selected turret wepon selection.  
End Type

;Constants INITIALIZE TURRETS___________________________________________________________________________
Const Turret_Rotations = 360
Const Total_num_turrets = 3 
Const numrotations=360
Const total_num_lazors = 3
Const SpaceBar=57 

Dim Turret_array_im(Total_num_turrets,Turret_Rotations)
Dim Bullet_Image(total_num_lazors,numrotations)
Dim xSinTable#(numrotations)                     ;Holds our SIN data
Dim yCosTable#(numrotations)                     ;Holds our COS data
;_______________________________________________________________________________________________________
;Function Calls INITIALIZE TURRETS______________________________________________________________________
;selection of player turrit images that shoot 360 directional bullets
;********************************************************************
lazor_cannon_im = CreateImage(20,20);	1							*
Make_lazorcannon_im(lazor_cannon_im);								*
;																	*
pulsar_cannon_im = CreateImage(20,20);	2							*
Make_pulsarcannon_im(pulsar_cannon_im);								*
;																	*
photon_cannon_im = CreateImage(20,20);	3							*
Make_photoncannon_im(photon_cannon_im);								*
;********************************************************************
Do_Turret_array(lazor_cannon_im,pulsar_cannon_im,photon_cannon_im)
Make_Turret_type(GraphicsWidth() Sar 1,GraphicsHeight() Sar 1,1)

;Make the 360 directional mouse guided bullets
green_lazor_im=CreateImage(6,20) ;index 1
Make_green_lazor(green_lazor_im)
MidHandle green_lazor_im

yellow_lazor_im=CreateImage(6,20) ;index 2
Make_yellow_lazor(yellow_lazor_im)
MidHandle yellow_lazor_im

purple_lazor_im=CreateImage(6,20) ;index 3
Make_purple_lazor(purple_lazor_im)
MidHandle purple_lazor_im

Do_lazor_array(green_lazor_im,yellow_lazor_im,purple_lazor_im)
PrecomputeSinCosTables()
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;*****************************************************************************************************

SetBuffer BackBuffer()
TFormFilter 1

quit = displaystartscreen()

While quit = False 
WaitTimer(frameTimer) 

	endgame = False
	
	old_level = 0 : control\level = 1 : control\nextextralife = 2500
	make_player	
	While endgame = False;Start of main Game loop_____________________start of main loop_________________
		WaitTimer(frameTimer);+++	
		If old_level <> control\level Then
			Introduce_Level
			;Make new bonneses and turrets for next leval 
			StartNewLevel
			old_level = control\level
		End If
		
		If player\lives<=0 Then endgame =True 
		
		time# = MilliSecs();Game Timing ????????????????????????????????????????????????????
		
		If player\score > control\nextextralife Then
			control\nextextralife = control\nextextralife + 2500
			player\lives = player\lives + 1
		End If
		
		Move_stars	
		Display_Info
		af = (af + 1) And 15 ;af___________af_______________af_______????????????????????
	
		min_x = control\xres
		max_x = 0
; ufo________________-ufo--------------ufo_______________ufo_____________--ufo_____________________
		new_ufo
		If ufo\status = True Then move_ufo

		bomb_count = 0
		For bombs = Each bomb_type
			bomb_count = bomb_count + 1
		 bombs\frame = bombs\frame + 1  ; +++ keep track of each frame of each bomb animation
		If bombs\frame = 16 Then bombs\frame = 0
			
		;DrawImage bomb_im1,bombs\x,bombs\y+10
		DrawImage bomb_im,bombs\x,bombs\y,bombs\frame
		
		
			 
			bombs\y = bombs\y + control\bomb_speed
		
			If ImagesCollide(bomb_im,bombs\x,bombs\y,0,bases(0),192,400,0) Then
				SetBuffer ImageBuffer(bases(0))
				Color 0,0,0
				bxp = bombs\x - 168
				byp = bombs\y -368
				draw_blank bxp,byp
				SetBuffer BackBuffer()
				Delete bombs
				bomb_count = bomb_count-1
			ElseIf ImagesCollide(bomb_im,bombs\x,bombs\y,0,bases(1),320,400,0) Then
				SetBuffer ImageBuffer(bases(1))
				Color 0,0,0
				bxp = bombs\x - 288
				byp = bombs\y -368
				draw_blank bxp,byp	
				SetBuffer BackBuffer()
				Delete bombs
				bomb_count = bomb_count-1
			ElseIf ImagesCollide(bomb_im,bombs\x,bombs\y,0,bases(2),448,400,0) Then
				SetBuffer ImageBuffer(bases(2))
				Color 0,0,0
				bxp = bombs\x - 420
				byp = bombs\y -368
				draw_blank bxp,byp
				SetBuffer BackBuffer()
				Delete bombs
				bomb_count = bomb_count-1
			ElseIf ImagesCollide(bomb_im,bombs\x,bombs\y,0,ship_im,player\x,player\y,0) Then
				If player\shield_Active = False Then
					bomb_count=bomb_count-1
					Player\lives = player\lives-1
					For i = 0 To 10
						ClsColor Rnd(255),Rnd(255),Rnd(255)
						Cls
						Flip
					Next
				End If
				Delete bombs
			Else If bombs\y > 480 Then
				Delete bombs : bomb_count=bomb_count-1
			End If
			
		Next

	
		check_bullets_and_bases
	
		player\moved = False;????????????????????????????????????????????????????????
		
		If MilliSecs()>player\shield_timer + 5000 Then;TTTTTTTTTTTTTTTTTTTTTTTTTTTTT
			player\shield_active = False
		Else
			Text 0,128,"Shield Active"
		End If
		
		If MilliSecs()>player\NES_Timer + 5000 Then
			player\Non_Expiring_Shot = False
		Else
			Text 0,144,"Non Expiring Shots"
		End If 
		
		
		If MilliSecs()>player\cluster_timer + 5000 Then
			player\cluster = False
		Else
			Text 0,160,"Cluster Fock"
		End If
		
		If MilliSecs()>Player\Speedy_Timer + 5000 Then
			control\player_speed = control\player_startspeed
			player\speedy = False
		Else
			Text 0,176,"Speedy"
		End If
		
		bomb_dropped = False
	
		beast_hit = False

		dokeys

		beast_count = 0
		
		mousepointer = 0
;Inside Main Loop ____________________________________________________________________________________
;LaunchBullet(Player_Turret\x,Player_Turret\y,Player_Turret\iDir)
If KeyHit(46) = True Then ;this goes in dokeys

	For Player_Turret.PTurret_type = Each PTurret_type
		;For i = 1 To 16
	 		LaunchBullet(Player_Turret\x,Player_Turret\y,Player_Turret\iDir,Player_Turret\selected)
		;Next 
	Next 
End If



picked = get_picked(picked);Get keyboard and mouse input and asign picked accordingly

mousepointer=pick_pointer(picked);

Pick_A_Turret(picked)

UpdateBullets()

;Hud()

;_____________________________________________________________________________________________________




AJ00200(Posted 2009) [#93]
	
For beast = Each beast_Type  ;Checking beasts 
		

		
			If beast\deleted = False Then
				beast_count = beast_count + 1
				x = beast\x + dir : y = beast\y
				If inc_y = True Then y = y + control\crit_drop_speed
				If dir > 0 Then
					If x > max_x Then max_x = x
				Else
					If x < min_x Then min_x = x
				EndIf
							
				If ImagesCollide(im(af), beast\x,beast\y,0,bases(0),192,400,0) = True Then;af 
					FreeImage bases(0) : bases(0) = CreateImage(1,1)
				Else If ImagesCollide(im(af), beast\x,beast\y,0,bases(1),320,400,0) = True Then;af
					 FreeImage bases(1) : bases(1) = CreateImage(1,1)
				Else If ImagesCollide(im(af), beast\x,beast\y,0,bases(2),448,400,0) = True Then;af
					FreeImage bases(2) : bases(2) = CreateImage(1,1)
				End If				
				beast\x = x
				beast\y = y

				DrawImage im(af),beast\x, beast\y ;Draw the beast images.              af
				
				;Check for Turret bullets to beast collisions
				For B.Tbullet = Each Tbullet
					If ImagesCollide(im(af),beast\x,beast\y,0,Bullet_Image(B\selected,B\iDir),B\dX#,B\dY#,0) Then
						Delete B
						Add_Point beast\x , beast\y
						player\score = player\score + 10
					
						beast_count = beast_count-1 : beast_hit = True
					
						Make_Explosion beast\x,beast\y,5	
									
						beast\deleted = True
						
						;If player\cluster = True Then 
							;bullet\x = bullet\x + (Rand(128)-64)
							;bullet\y = bullet\y + (Rand(128)-64)
						;Else If player\non_expiring_shot = False Then 
							;bullet\fired = False
						;End If

					EndIf 
				
				Next 
				
				For bullet.Bullet_Type = Each Bullet_Type
				;If bullet <> Null Then 
				If bullet\fired = True Then;row 1069
					If ImagesCollide(im(af),beast\x,beast\y,0,bim,bullet\x,bullet\y,0) Then ;af

						Add_Point beast\x , beast\y
						player\score = player\score + 10
					
						beast_count = beast_count-1 : beast_hit = True
					
						Make_Explosion beast\x,beast\y,5	
									
						beast\deleted = True
						
						If player\cluster = True Then 
							bullet\x = bullet\x + (Rand(128)-64)
							bullet\y = bullet\y + (Rand(128)-64)
						Else If player\non_expiring_shot = False Then 
							bullet\fired = False
						End If
						
					EndIf
				EndIf
				;EndIf 
				Next 
				 
				If bomb_dropped = False Then
					If bomb_count < control\max_bombs Then
						If Rand(100)<control\drop_bomb_chance Then
							bomb_count = bomb_count+1
							bomb_dropped = True
							bombs = New bomb_type
							bombs\x = beast\x : bombs\y = beast\y
						EndIf
					EndIf
				EndIf
				
			EndIf
			
			If beast\y > 460 Then endgame = True
		Next ;end of beasts checking
	
		If beast_hit = True Then Increase_Beast_Speed
  
		inc_y = False
		If dir >0 Then
			If max_x > 608 Then dir = -dir : inc_y = True
		Else
			If min_x < 32 Then dir = - dir : inc_y = True
		EndIf
;Game update section *******************************************************************************
;***************************************************************************************************
;***************************************************************************** Game update section
		Do_Points	
		DoExplosion
		Move_Bonus_Item
		If ufo\status = True Then Check_Bullets_And_Ufo;ufo_____________ufo_____________________
		;If time# > frameTimer Then
			Move_And_Draw_Bullet
		;EndIf 
		If beast_count = 0 And ufo\status = False Then control\level = control\level + 1
		
		DrawImage ship_im,player\x,player\y
		
		;For Player_Turret.PTurret_Type = Each PTurret_Type
		
			;DrawImage Player_Turret\image,player\x,player\y
			;DrawImage Player_Turret\image,player\x,player\y
			;DrawImage Player_Turret\image,player\x,player\y
			;DrawImage Player_Turret\image,player\x,player\y


		;Next 
		;update_turret(player\x,player\y,drawcurent)
		;update_turret(player\x,player\y,lazor_cannon_im)
		
		;update_turret(player\x,player\y,pulsar_cannon_im)
		
		;update_turret(player\x,player\y,photon_cannon_im)


		DrawImage bases(0),192,400
		DrawImage bases(1),320,400
		DrawImage bases(2),448,400
	
		;Color 255,255,255
		;mousepointer=0
		;move Left
		If MouseDown (1) Then 
			mousepointer = 1
		End If
		;move Right 
		If MouseDown (2) Then 
			mousepointer = 2
		End If
		
 
		;DrawImage targetpointimage1,100,100 
		;DrawImage targetpointimage2,100,150 
		;DrawImage targetpointimage3,100,200 
		;DrawImage targetpointimage4,100,250
		;DrawImage targetpointimage5,100,300
		
		;For Player_Turret.PTurret_Type = Each PTurret_Type
			;DrawImage Player_Turret\image,100,350
		;Next 

		;Color 255,100,100
		;Line player\x,player\y-7,MouseX(),MouseY()
		;Color 0,0,0
		;Line player\x,player\y-10,MouseX()+1,MouseY()
		;Color 0,0,0
		;Line player\x,player\y-10,MouseX()-1,MouseY()
		;DrawImage bullet_im,150,100
		
		
		;If time# > rtimer# Then 

			;rframe=rframe+1
		    ;If rframe = 16 rframe = 0
			;DrawImage Quazar_im,150,150,rframe
			;If rframe > 2 
				;DrawImage Quazar_im,150,150,rframe-1

			;EndIf 
			;If rframe > 4
				;DrawImage Quazar_im,150,150,rframe-2

			;EndIf 

			;rawImage Quazar_im,150,150,rframe

			
			
			;DrawImage rappedfire_im,150,200,bullet\frame
			;DrawImage bomb_im,150,250,rframe

		;EndIf 

		



		
		

		
		;Text 30,420,"adjusttimer " + adjusttimer
		Color 100,200,100
		Text 20,420," Total vidio memory ; " + TotalVidMem()
		Text 275,420, "Available vidio memory : " + AvailVidMem ()
		Text 500,30, "Total beasts : " + total_beasts
		Memory_in_use = TotalVidMem() - AvailVidMem ()
		Text 20,440," Total vidio memory - " + "Available vidio memory  " + Memory_in_use
		


		VWait   
		
		 Flip False   
		rtimer# = MilliSecs()
  		If KeyDown (13) Then 
			adjusttimer = adjusttimer - 1
		EndIf
		If KeyDown (12) Then 
			adjusttimer = adjusttimer + 1
		EndIf 
		;EndIf 
		
		Delay adjusttimer
	Wend
	
	DisplayEndScreen
	EnterHighScore
	endgame = False
		
	;Delay(500)
	FlushKeys
	
	quit = displaystartscreen()	
Wend;main____________________MMMAAAIIINNN___________________end of main loop!
End


Function Set_Up_Control()
control.Control_Type = New Control_Type
control\max_bombs = 5
control\bomb_speed = 3
control\crit_drop_Speed = 17
control\drop_bomb_chance = 5
control\player_StartSpeed = 4
control\player_speed = control\player_StartSpeed
control\bullet_speed = 20
control\max_rows = 6
control\max_cols = 10
control\xres = 640 ; Try this pair at different resolution: 640,480 or 1024,768 or 1280,1024
control\yres = 480; 
control\depth = 32;
control\level = 1
control\Beast_Speed = 2
control\Beast_Speed_Increment = .05
;+++ speed and direction of ufo
control\UFO_Speed = 2
control\UFO_dir = 0




End Function

Function Do_Points()
For point = Each points_type
	DrawImage points_Ims(point\id),point\x,point\y
	point\id = point\id + 1
	If point\id > 15 Then Delete point
Next
End Function

Function Make_Ship()
ship = CreateImage(64,16)
SetBuffer ImageBuffer(ship)
Rect 0,8,64,8,True
Rect 16,4,32,4,True
Rect 24,0,16,4,True
SaveImage ship,"images\ship01.bmp"
End Function

Function DoKeys()

 
If KeyDown(57) Then
For bullet.Bullet_Type = Each Bullet_Type

	If bullet\fired = False Then
		bullet\x = player\x : bullet\y = player\y
		bullet\fired = True
		
		
			
			
			
			If ChannelPlaying (fifthsound) = 0  Then 
				fifthsound=PlaySound ( shootSound )
				ChannelPitch fifthsound,5600
				
			ElseIf ChannelPlaying (fifthsound) = 1 Then 
				StopChannel fifthsound
				FreeSound fifthsound  

 			EndIf 
		

	EndIf
Next	
EndIf

If player\moved = False Then
	If KeyDown(205) Or MouseDown (2) Then
		If player\x < 608 Then player\x = player\x + control\player_speed : player\moved = True
	EndIf
		
	If KeyDown(203) Or MouseDown (1) Then
		If player\x > 16 Then player\x = player\x - control\player_speed : player\moved = True
	EndIf
EndIf

If KeyDown(1) Then EndGame = True

End Function

Function DoExplosion()
For explosion = Each explosion_type
	DrawImage debri(explosion\id), explosion\x, explosion\y
	Select explosion\status
		Case 0
			explosion\dirx = Int(Rand(.5))-.5
			explosion\diry = Int(Rand(.5))-.5
			explosion\status = 1
			explosion\count = 1
			
		Case 1
			explosion\x = explosion\x + explosion\dirx
			explosion\y = explosion\y + explosion\diry
			explosion\count=explosion\count - 1 
			If explosion\count<=0 Then explosion\status = 2
		Case 2
			explosion\y=explosion\y+explosion\speed
			If explosion\y > 480 Then Delete explosion
		Default
			; There should be no other options so delete the explosion
			Delete explosion
	End Select		
Next
;+++ secondary weapon selection
	Select MouseZSpeed ()
		Case -1
			zspeed=zspeed+1
		Case 0
			zspeed=0
		Case 1
			zspeed=zpeed-1
	End Select
	 
End Function

Function Check_Bullets_And_UFO()
For bullet.Bullet_Type = Each Bullet_Type
If bullet\fired = True Then
	If ufo\status = True Then
		If ImagesCollide(ufo_Im,ufo\x,ufo\y,0,bullet_im,bullet\x,bullet\y,0) Then
			ufo\status = False
			Make_Explosion ufo\x,ufo\y,25
			player\score = player\score + 50
			If bonus\active = False Then
				bonus\active = True
				bonus\x = ufo\x : bonus\y = ufo\y
			End If
		EndIf
	EndIf
EndIf
Next 
End Function

;Function Move_And_Draw_Bullet()
	;bullet\y = bullet\y - control\bullet_Speed              " old function"
	
	;DrawImage bullet_im,bullet\x,bullet\y
;
;End Function

Function Make_Bullet()
; This creates the players bullet used throughout the whole game
	bullet.Bullet_Type = New Bullet_Type	; create bullet
	bullet\fired = False		; set that it's not been fired
	bullet\frame = 0
End Function

Function Move_And_Draw_Bullet()
For bullet.Bullet_Type = Each Bullet_Type
	bullet\y = bullet\y - control\bullet_Speed 
	           
	If bullet\y < 1 Then 
		;dest = True
	Else 
		dest = False 
	EndIf
	;If bullet\y < 0 Then 
				
			;EndIf 
 
	
	Select dest
	
		Case False   
	
		;If MilliSecs() > rtimer# Then 
	
			bullet\frame = bullet\frame + 1 
			If bullet\frame = 16 Then bullet\frame = 0 
			DrawImage rappedfire_im,bullet\x,bullet\y,bullet\frame
		
		;EndIf
		
		Case True 
		

			Delete bullet
			
			;If bullet = Null Then 
				;d = d + 1
			;EndIf 
			 
		End Select 
	
Next 
d = d + 1		
Text 100,300,"d :" + d	 
End Function


Function Check_Bullets_And_Bases()
For bullet.Bullet_Type = Each Bullet_Type

	If bullet\fired = True Then
		For i = 0 To 2
			If ImagesCollide(bases(i),192+(i*128),400,0,bullet_im,bullet\x,bullet\y,0) Then
				If player\Non_Expiring_Shot = False Then bullet\fired = False
					SetBuffer ImageBuffer(bases(i))
					
				
					xp = bullet\x - (160 + (i * 128))

					yp = bullet\y - 380
				
					draw_Blank xp,yp
					SetBuffer BackBuffer()
			EndIf
			If bullet\fired = False Then Exit
		Next

		If bullet\y < 0 Then 
			bullet\fired = False
			
		EndIf
	EndIf
Next 
End Function



Function Make_Points_Ims()
For i = 0 To 15
	Points_Ims(i) = CreateImage(32,32)
	Color 0,255-(i Shl 4), 0
	SetBuffer ImageBuffer(Points_Ims(i))
	Oval 16-i,16-i,i Shl 1 ,i Shl 1,False
	Text 16,16,"10",True,True
Next	
End Function

Function Add_Point(x,y)
	point = New points_type
	point\x = x : point\y = y
	point\id = 0
End Function

Function Move_Stars();Move stars*********************************************************

	stars(0)\y = (stars(0)\y -1) And 255
	TileBlock stars(0)\image,stars(0)\x,stars(0)\y

	stars(1)\y = (stars(1)\y-2) And 255
	TileImage stars(1)\image,stars(1)\x+4,stars(1)\y

	stars(2)\y = (stars(2)\y-4) And 255
	TileImage stars(2)\image,stars(2)\x,stars(2)\y

End Function

Function Make_Stars()

stars(0) = New stars_type
stars(0)\image = CreateImage(256,256)
stars(0)\count = Rand(256)
stars(0)\x = Rand(256)
SetBuffer ImageBuffer(stars(0)\image)
Color 64,64,255
For i = 0 To 31
	x = Rand(256)
	y = Rand(256)
	Rect x,y,1,1,True
Next

stars(1) = New stars_type
stars(1)\count = Rand(256)
stars(1)\x = Rand(256)
stars(1)\image = CreateImage(256,256)
SetBuffer ImageBuffer(stars(1)\image)
Color 128,128,128
For i = 0 To 16
	x = Rand(256)
	y = Rand(256)

	Rect x,y,1,1,True
Next

stars(2) = New stars_type
stars(2)\count = Rand(256)
stars(2)\x = Rand(256)
stars(2)\image = CreateImage(256,256)
SetBuffer ImageBuffer(stars(2)\image)
Color 255,255,255

For i = 0 To 15
	x = Rand(256)
	y = Rand(256)
	Rect x,y,1,1,True
Next

End Function

Function New_Ufo()

If ufo\status = False Then
;+++ set up a local variable to determon when ufo appears. it will also 
;deside what side of the screen it comes from (ufo_comes). If the UFO comes from the Left side of the 
;screen we use 8 becouse we want to use the 8th image from the 16 rotations image array.   
ufo_comes=Rnd(1000)
	If ufo_comes < 10 Then
		If ufo_comes < 5 Then
			control\ufo_speed=-Rnd(2,4)
			control\ufo_dir=8 ;+++ Face Left
			ufo\status = True
			ufo\x = 0
			ufo\y = 25
		EndIf 
		If ufo_comes > 5 Then
			control\ufo_speed=Rnd(2,4)
			control\ufo_dir=0 ;+++ Face Right
			ufo\status = True 
			ufo\x = 640
			ufo\y = 25
		EndIf 
 	EndIf
EndIf

End Function

Function Move_Ufo()

	ufo\x = ufo\x - control\ufo_speed
	If ufo\x < 0 Or ufo\x > 640 Then
		ufo\status = False
	EndIf
	;DrawImage ufo_im,ufo\x,ufo\y
	DrawImage rot_im_array(control\ufo_dir),ufo\x,ufo\y

End Function

;Function Make_Ufo_Old()
	;ufo_im = CreateImage(64,16)
	;Color 0,255,0
	;SetBuffer ImageBuffer(ufo_im)
	;Oval 32,8,32,8,True
;End Function

Function Draw_Blank(xp,yp)
	MaskImage blank_im,0,0,0
	DrawImage blank_im,xp,yp
End Function

Function Make_Blank()
	SetBuffer ImageBuffer(blank_im)
	MaskImage blank_im,255,0,255
	Color 255,0,255
	Rect 0,0,6,24,True
End Function

Function Make_Collision_Image();Bim=========Bim======Bim=========Bim========Bim=========Bim
bim = CreateImage(24,24)
SetBuffer ImageBuffer(bim)
ClsColor 0,0,0
Cls
Color 255,255,255
Oval 8,8,8,8,True
SetBuffer BackBuffer()

End Function

Function Make_Debri()
; This function creates the images used for the debri of the beasts ships
; It creates 15 images to choose from to use for falling debri by
; creating an image, setting the draw buffer to the image buffer, setting a random colour,
; and finally drawing a solid rectangle in that color
For i = 0 To 15
	debri(i) = CreateImage(2,2)
	SetBuffer ImageBuffer(debri(i))
	Select Rand(3)
		Case 0
			Color Rand(255),0,0
		Case 1
			Color 255,Rand(255),0
		Case 2
			Color 255,255,255
		Default
			Color 255,255,0
	End Select
	Rect 0,0,2,2,True
	
Next
End Function

Function Make_Player()
; This creates the player
player\x = 320 : player\y = 460			; position player on screen
player\score = 0
player\lives = 3
End Function

Function Make_Beasts()
; this produces a grid of beasts and puts them into their correct positions on screen
Delete Each beast_type
total_beasts = 0
beast_count = 0
For y = 0 To control\max_rows		; go through the rows
	For x = 0 To control\max_cols	; go through the columns
		beast = New beast_type		; create a new beast
		beast\x = x * 32.00			; place it at position using logical arithmetic, equivalent to x * 32
		beast\y = y * 32.0 + 64.0		; place it at position using logical arithmetic, equivalent to (y * 32)+32
		beast_count = beast_count + 1	; increase the number of beasts
	Next
Next

total_beasts = beast_count	; we need to know how many there originally were

End Function


Function Increase_Beast_Speed()
If dir < 0 Then 
	dir = dir - control\beast_speed_increment	
Else
	dir = dir + control\beast_speed_increment	
EndIf
End Function

Function Make_Explosion(x,y,sparks)
For i = 0 To sparks
	explosion = New explosion_type
	explosion\x = x + Rand(50)-25
	explosion\y = y + Rand(50)-25
	explosion\speed = Rand(10)+1
	explosion\status = 0
	explosion\id = Rand(15)
Next
End Function

Function DisplayStartScreen()
SetBuffer BackBuffer()
screentimer# = MilliSecs()
display_highscore = False

done = False : quit = False
While Not done
	WaitTimer(frameTimer);+++

	Cls
	move_stars
	If KeyDown(1) Then done = True : quit = True
	If KeyDown(57) Then done = True
	If display_highscore = False Then 
		SpaceyText 400,100,"SPACE INVADERS",True
		SpaceyText 400,164,"SPACE TO BEGIN",True
		SpaceyText 400,196,"ESC TO EXIT",True
	Else
		SpaceyText 400,100,"High Score Table",True
		For i = 0 To 9
			SpaceyText 200,116 + (i Shl 4), highscores(i)\score, False
			SpaceyText 400,116 + (i Shl 4), highscores(i)\name, False
		Next
	End If
	
	If MilliSecs()>(screentimer+5000) Then 
		screentimer = MilliSecs()
		display_highscore = Not(display_highscore)
	End If
	Flip	
Wend

Return quit
FlushKeys
End Function

Function Display_Info()
	Text control\xres - (Len(Str(player\score))*16),0,player\score
	For i = 0 To (player\lives-1)
		DrawImage ship_im, 32 + i Shl 6, 16
	Next 
End Function

Function DisplayEndScreen()
	FlushKeys
	screentimer = MilliSecs()
	While MilliSecs()<screentimer+2000
	WaitTimer(frameTimer);+++

		Cls
		Move_Stars
		SpaceyText 200,400,"GAME OVER",True
		Flip
	Wend
	FlushKeys
End Function

Function Make_SpaceyFont()
For i = 0 To 39
	SpaceyFont(i) = CreateImage(32,48)
	MidHandle SpaceyFont(i)
	SetBuffer ImageBuffer(SpaceyFont(i))
	ch$ = Mid$(char$, i+1,1)
	Select ch
		Case "@"
			Text 4,8,"DEL"
		Case "#"
			Text 4,8,"END"
		Case "~"
			Rect 0,0,32,32,False
		Default 
			Text 12,8,ch$
	End Select
Next
End Function

Function EnterHighScore()
name$ = ""
pos = 10
For i = 9 To 0 Step -1
	If player\score>highscores(i)\score Then pos = i
Next

If pos<10 Then
	done = False
	
	x = 0 : y = 0

	keypresstimer# = MilliSecs()
	keypressed = False
	
	While Not(done)
	WaitTimer(frameTimer);+++

		Cls
		Move_Stars
		yp = 0 : xp = 0
		For i = 0 To 38
			DrawImage SpaceyFont(i),160 + xp * 32, 100 + yp * 32
			xp = xp + 1 : If xp>9 Then xp = 0 : yp=yp+1
		Next	
				
		If keypressed = False Then
			If KeyDown(203) Then x = x - 1 : keypressed = True : If x < 0 Then x = 9
			If KeyDown(205) Then x = x + 1 : keypressed = True : If x > 9 Then x = 0
			If KeyDown(200) Then y = y - 1 : keypressed = True : If y < 0 Then y = 3
			If KeyDown(208) Then y = y + 1 : keypressed = True : If y > 3 Then y = 0

			If KeyDown(57) Then
				keypressed =True
				ch = (x + y*10)+1
				Select Mid(char$,ch,1)
					Case "@"
						If Len(name)>0 Then
							name = Left(name, Len(name)-1)
						End If
					Case "#"
						done = True
					Case "~"
					Default
						If Len(name)<5 Then name = name + Mid(char$,ch,1)
				End Select
			End If			

			If keypressed = True Then keypresstimer = MilliSecs()

		End If
	
		If MilliSecs()>keypresstimer + 100 Then keypressed = False
		
		If ((x) + (y*10)) > 38 Then x = x -1		
		DrawImage SpaceyFont(39), 160 + x * 32, 100 + y * 32
		
		SpaceyText 100,400,name,True
		If KeyDown(1) Then done = True
		Flip
	Wend
		
	For i = 8 To pos Step -1
		highscores(i+1)\score = highscores(i)\score
		highscores(i+1)\name = highscores(i)\name
	Next
	
	highscores(pos)\score = player\score
	highscores(pos)\name = name
End If
End Function

Function Make_Highscoretable()
For i = 9 To 0 Step -1
	highscores(i) = New highscoretable_type
	highscores(i)\score = score
	highscores(i)\name = "Bob"
	score = score + 100
Next
End Function

Function StartNewLevel()
	Delete Each bomb_type
	Make_Beasts
	Make_Bases
	
	


	control\Beast_Speed = 1 + (control\level/2)
	dir = control\beast_speed
End Function

Function Introduce_Level()
timer# = MilliSecs()
While MilliSecs()<timer + 500
	WaitTimer(frameTimer);+++

	Cls
	Move_Stars
	SpaceyText 300,200,"Level : " + control\level, True
	Flip
Wend
End Function

Function Make_Player_Image()
ship_im = CreateImage(50,50)
SetBuffer ImageBuffer(ship_im)
;ClsColor 0,0,0
;Color 255,255,255
;Rect 24,0,16,4,True
;Rect 16,4,32,4,True
;Rect 8,8,48,4,True
;Rect 0,12,64,4,True
;ship
;drawing of player ship
For i = 1 To 15
	Color 100-(i*5),100-(i*5),100-(i*5)

	Line 15-(i/10),15+i,35+(i/10),15+i ;front underchasi
Next
For i = 1 To 15
	Color 100-(i*5),100-(i*5),100-(i*5)

	Line 14+i/4,30+i,36-i/4,30+i ;rear under chassi
Next 
For i = 1 To 10
	Color 100-(i*5),100-(i*5),100-(i*5)

	Line 23-(i/2),0+i,27+(i/2),0+i ;nose
Next
For i = 1 To 15
	Color 80-(i*5),80-(i*5),80-(i*5)

	Line 17+(i/7),10+i,33-(i/7),10+i ;neck	
Next
For i = 1 To 15
	Color 80+i,80+i,80+i

	Line 23-i,17+i,27+i,17+i ;front of wing
Next
For i = 1 To 5
	Color 80-i,80-(i*2),80-i

	Line 10,32+i,40,32+i ;rear of wing
Next
For i = 1 To 5
	Color 80-(i*5),80-(i*5),80-(i*5)

	Line 20,45+i,30,45+i
Next 
For i = 1 To 3
	Color 100-(i*15),100-(i*15),100-(i*15)
	Line 6-i,15,6-i,40         ; rockets
	Line 6+i,15,6+i,40

	Line 44-i,15,44-i,40
	Line 44+i,15,44+i,40
Next
For i = 1 To 5
	Color 50,50,50
	Line 3+(i/2),15-i,9-(i/2),15-i
	Line 41+(i/2),15-i,47-(i/2),15-i
Next 
Line 3,15,9,15
Line 41,15,47,15
Color 120,120,120 ;rocket detail
Line 6,10,6,40
Line 44,10,44,40
For i = 1 To 4
Color 60-i,60-i,60-i
	Line 3,41,9,41
	Line 41,41,47,41
	Line 3-Floor(i/2),41+i,9+Floor(i/2),41+i  ;rocket flares
	Line 41-Floor(i/2),41+i,47+Floor(i/2),41+i
Next
Color 120,120,120
Line 6,41,6,45 ;left flare details
Line 3,41,1,45
Line 9,41,11,45
Line 44,41,44,45 ;Right flare details
Line 41,41,39,45
Line 47,41,49,45
 ;ship highlights and little details
Color 140,50,50
Line 23,17,27,17
For i = 1 To 5
	Color 120-(i*10),50,50   ;window with red light reflection on nose
	Line 23-i,16-i,27+i,16-i
Next

For i = 1 To 12
	Color 80+i*2,80+i*2,80+i*2 
	Line 23-i,20+i,27+i,20+i
Next

For i = 10 To 40 Step 5 ;some back detail to break up the color a little
	Color 120,120,120
	Line 0+i,32,0+i,37
Next 
;For i = 1 To 3
	;Color 100-(i*15),100-(i*15),100-(i*15)
	;Line 25-i,20,25-i,45-i
	;Line 25+i,20,25+i,45-i
;Next 
;Color 120,120,120 
ScaleImage ship_im,.75,.75
SetBuffer BackBuffer()
End Function

Function Make_Beast_Images()
For i = 0 To 15

	im(i) = CreateImage(50,50)
	SetBuffer ImageBuffer(im(i))

For l = 1 To 4
	Color 50+(l*5),100+(l*5),50+(l*5)
	Line 25+l,0+(l*2),25+l,25-(l*2)  ;center body
	Line 25-l,0+(l*2),25-l,25-(l*2)
Next 
For l = 1 To 8
	Color 50+(l*5),100+(l*5),50+(l*5)
	Line 30+l,10+l,30+l,15+l ;Right wing
	Line 20-l,10+l,20-l,15+l ;left wing
Next 

Color 20,60,20
Line 30,10,30,15 ;Right wing start
Line 20,10,20,15 ;left wing start
For l = 1 To 3
	Color 50-(l*5),100-(l*10),50-(l*5)
	Line 10+l,10+l,10+l,35-(l*3)	;left rocket
	Line 10-l,10+l,10-l,35-(l*3)
	Line 40+l,10+l,40+l,35-(l*3)	;right rocket
	Line 40-l,10+l,40-l,35-(l*3)
Next 

Color 30,30,30
For l = 1 To 5

	Line 25+Ceil(l/2),23-l,25-Ceil(l/2),23-l
Next 
Color 50,100,50
Plot 25,23
Line 25,0,25,17     ;center body
Line 10,10,10,35	;left rocket
Line 40,10,40,35	;right rocket



Next


For i = 0 To 15
	ScaleImage im(i),.75,.75
Next



SetBuffer BackBuffer()
End Function



AJ00200(Posted 2009) [#94]
[codebox]
Function Make_Beast_Images_2()
For i = 0 To 15
im2(i) = CreateImage(50,50)
SetBuffer ImageBuffer(im2(i))



For l = 1 To 10
Color 80+l,60-l,60-l
Line 23-(l/2),40-l,27+(l/2),40-l ;nose
Next
For l = 1 To 5
Color 80+(l*5),40-l,40-l

Line 30,32,30,20 ;right wing
Line 30+l,32+l,30+l,20-l
Line 20,32,20,20 ;left wing
Line 20-l,32+l,20-l,20-l
Next
For l = 1 To 5
Color 75+(l*10),20+l,55+l
Line 45,27,45,20
Line 45-l,27+l*2,45-l,20-l*2 ;right outer wing
Line 5,27,5,20
Line 5+l,27+l*2,5+l,20-l*2 ;left outer wing
Next
For l = 1 To 3
Color 120,120-(l*10),120-(l*10)
Line 38-l,40-l,38-l,10+l*2;right rocket
Line 38+l,40-l*2,38+l,10-l*2
Line 12-l,40-l,12-l,10-l*2;left rocket
Line 12+l,40-l,12+l,10+l*2
Next
Color 140,125,125
Line 38,40,38,10 ;rocket highlights
Line 12,40,12,10
For l = 1 To 7
Color 20+(l*2),20+(l*2),20+(l*2)
Line 23-(l/2),38-l,27+(l/2),38-l ;cockpit
Next
For l = 1 To 4
Color 120,120-(l*10),120-(l*10)
Line 25-l,30,25-l,15-Floor(l*1.75)
Line 25+l,30,25+l,15-Floor(l*1.75)
Next
Color 140,125,125
Line 25,30,25,15
Next

For l = 0 To 15
ScaleImage im2(l),.65,.65
Next

End Function

Function Make_Base_Image()
base_im = CreateImage(64,32)
MaskImage base_im,255,0,255
SetBuffer ImageBuffer(base_im)
Color 64,64,64
Rect 0,0,64,64,True
Color 255,0,255
For s = 0 To 15
Line s,0,0,15-s
Line 48+s,0,64,s
Next
End Function

Function Make_Bases()
For i = 0 To 3
bases(i) = CopyImage(base_im)
MaskImage bases(i),255,0,255
Next
End Function

Function Make_Bombs1()
SetBuffer ImageBuffer(bomb_im1)
Color 0,255,0
For i = 0 To 31
If i And 1 Then Plot 0,i Else Plot 1,i
Next
End Function

Function Make_Bombs()
For frame = 0 To 15

SetBuffer ImageBuffer(bomb_im,frame)

midx = ImageWidth(bomb_im)/2;+Rnd(-3,3)
midy = ImageHeight(bomb_im)/2;+Rnd(-3,3)


;TFormFilter


;Color 255,0,0
For l = 0 To 200
;Plot Rnd(ImageWidth(Quazar_im)),Rnd(ImageHeight(Quazar_im))
Color Rnd(225,255),Rnd(225),Rnd(0,25)
;Color 255,255,0
;Color 0,255,0


;Line midx,midy,Rnd(-(midx+fr),midx+frame),Rnd(-(midy+frame),midy+frame)
Line midx,midy,Rnd(midx-10,midx+10),Rnd(midy-10,midy+10)
;Color 255,255,250


;Line midx,midy,Rnd(-(midx+fr),midx+frame),Rnd(-(midy+frame),midy+frame)
;Line midx,midy,Rnd(midx-10,midx+10),Rnd(midy-10,midy+10)


Color 205,205,255
Plot midx+Rnd(-1,1),midy+Rnd(-1,1)

Next
;Goto skipthis

If frame < 7 Then
For l = 0 To 10
;Plot Rnd(ImageWidth(Quazar_im)),Rnd(ImageHeight(Quazar_im))
;Color Rnd(25,255),Rnd(25,255),Rnd(205,255)
Color 55,255,0
Line midx,midy,Rnd(midx-15,midx+15),Rnd(midy-15,midy+15)



;Line midx,midy,Rnd((midx-frame),(midx+frame)),Rnd(-(midy+frame),(midy+frame))
;Color 205,205,255
;Plot midx+Rnd(-1,1),midy+Rnd(-1,1)

Next
EndIf
If frame < 10 Then
For l = 0 To 10
;Plot Rnd(ImageWidth(Quazar_im)),Rnd(ImageHeight(Quazar_im))
;Color Rnd(25,255),Rnd(25,255),Rnd(205,255)
Color 10,255,10
Line midx,midy,Rnd(midx-15,midx+15),Rnd(midy-15,midy+15)



;Line midx,midy,Rnd((midx-frame),(midx+frame)),Rnd(-(midy+frame),(midy+frame))
;Color 205,205,255
;Plot midx+Rnd(-1,1),midy+Rnd(-1,1)

Next
EndIf

;.skipthis
;.skipthis
For l = 0 To 40
;Plot Rnd(ImageWidth(Quazar_im)),Rnd(ImageHeight(Quazar_im))
;Color Rnd(5,255),Rnd(5,255),Rnd(205,255)
Color 0,0,0
Line midx,midy,Rnd(midx-5,midx+5),Rnd(midy-5,midy+5)
If l=>1 Then
Line midx,midy,Rnd(midx-8,midx+8),Rnd(midy-8,midy+8)
EndIf
If l=>1 Then
Line midx,midy,Rnd(midx-15,midx+15),Rnd(midy-15,midy+15)
EndIf

;Line midx,midy,Rnd(midx-10,midx+10),Rnd(midy-1,midy+1)
;Line midx,midy,Rnd(midx-2,midx+2),Rnd(midy-10,midy+10)
;Line midx,midy,Rnd(midx-10,midx+10),Rnd(midy-1,midy+1)

;Line midx+l,midy+l,Rnd(midx-10,midx+10),Rnd(midy-10,midy+10)
;Line midx-l,midy-l,Rnd(midx-10,midx+10),Rnd(midy-10,midy+10)


;Line midx,midy,Rnd(-(midx+frame),midx+frame),Rnd(-(midy+frame),midy+frame)
;Color 205,205,255
;Plot midx+Rnd(-1,1),midy+Rnd(-1,1)

Next
;.skipthis

;center
funct_used = funct_used+1
Color 200+frame*3,200+frame*3,200+frame*3
Color 255,55,200
Plot midx,midy+1
Plot midx+1,midy
Plot midx-1,midy
Plot midx,midy-1
Color 20+frame*10,255+frame*10,255
Color 255,0,0
;lite rays******************************************************
Plot midx+frame,midy
Plot midx+frame/2,midy


Plot midx,midy+frame
Plot midx,midy+frame/2
;Color 255,255,255
Plot midx,midy-frame
Plot midx,midy-frame/2


Plot midx-frame,midy
Plot midx-frame/2,midy

;diagonals
Color 20,20,255
Color 255,0,0
Plot midx+frame,midy+frame
Plot midx-frame,midy-frame
Plot midx-frame,midy+frame
Plot midx+frame,midy-frame
Color 20,20,255
Color 255,0,0
Plot midx+frame/2,midy-frame/2;tn
Plot midx+frame/2,midy+frame/2;to
Plot midx-frame/2,midy-frame/2;th
Plot midx-frame/2,midy+frame/2;th
Plot midx+frame/3,midy
Plot midx+frame/4,midy
Plot midx,midy+frame/3
Plot midx,midy+frame/4
Plot midx,midy-frame/3
Plot midx,midy-frame/4
Plot midx-frame/3,midy
Plot midx-frame/4,midy
;diagonals end
;Color 255,255,255



;endof lite rays*********************

;MaskingMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
Color 0,0,0
;Oval midx,midy,3+frame,3+frame,1
;Oval midx-4+frame,midy-4+frame,9-frame,9-frame,1
Oval -4,-4,ImageWidth(Quazar_im)+8,ImageHeight(Quazar_im)+8,0
Oval -3,-3,ImageWidth(Quazar_im)+6,ImageHeight(Quazar_im)+6,0
Oval -2,-2,ImageWidth(Quazar_im)+4,ImageHeight(Quazar_im)+4,0
Oval -1,-1,ImageWidth(Quazar_im)+2,ImageHeight(Quazar_im)+2,0
Oval 0,0,ImageWidth(Quazar_im),ImageHeight(Quazar_im),0
;Oval 0,0,ImageWidth(Quazar_im),ImageHeight(Quazar_im),0

Color 0,0,0
;Color 2,255,255 ; blue 1
Oval -6,-6,14,14,1
;Color 255,255,255
Oval ImageWidth(Quazar_im)-5,-4,15,14,1 ;white 2
;Color 2,255,25
Oval midx+3,midy+3,15,15,1 ;green 3
;Color 2,55,0
;Oval -5,midy-5,-12,-12,1
Oval -5,midy+5,15,15,1


;Oval -7,-7,15,15,1
;Oval ImageWidth(Quazar_im)-5,-5,10,10,1
;Oval midx+5,midy+5,10,10,1
;Oval -5,midy+5,10,10,1

;MaskingMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
;For l= 0 To 1
;Color Rnd(255),Rnd(255),Rnd(255)
;Plot midx+Rnd(-1,1),midy+Rnd(-1,1)
;Next
;DebugLog frame
;SetBuffer ImageBuffer(Quazar_im,frame)

;ResizeImage Quazar_im,frame,frame
;


Next

;For frame = 0 To rotations - 1
;rot_im_array(frame) = CopyImage(bitmap)
;RotateImage rot_im_array(frame), frame * 360/rotations
;DebugLog "rotations "+ rotations

;Next

For r = 9 To 10
SetBuffer ImageBuffer(Quazar_im,r)




angle# = r
If angle# > 359 angle#=0
;ResizeImage bomb_im,5.0*f,5.0*f
RotateImage bomb_im,angle#
DrawImage bomb_im,midx,midy,angle#

Next

;For f = 14 To 15

;SetBuffer ImageBuffer(bomb_im,f)
;angle# = f
;ResizeImage bomb_im,5.0*f,5.0*f
;RotateImage bomb_im,-angle#

;Next


;For f = 0 To 15

;SetBuffer ImageBuffer(bomb_im,f)
;angle# = f
;If f > 12
;ResizeImage bomb_im ,20,30
;EndIf
;RotateImage bomb_im,angle#

;Next









End Function


;BULLET********************BULLETS*********************BULLETS****************************BULLETS
Function Make_Bullets_im() ;standard bullets
SetBuffer ImageBuffer(bullet_im)
midx=ImageWidth(bullet_im)/2
midy=ImageHeight(bullet_im)/2

Color 255,100,200
;For i = 0 To 8
;Plot midx,midy+i
;Plot midx,midy-i

;Next
Color 255,0,0

For i = 0 To 6

Plot midx+1,midy+i

Plot midx+1,midy-i
Plot midx-1,midy+i
Plot midx-1,midy-i

Next
Color 0,0,0
;Line midx,midy-5,midx+1,midy
;Line midx,midy+5,midx+1,midy
;Line midx,midy-5,midx-1,midy
;Line midx,midy+5,midx-1,midy
;Line midx,midy-9,midx,midy+9
;Color 255,0,0
;Plot midx,midy
End Function

Function Make_rappedfire() ;rappedfire bullets+++
For frame = 0 To 15
;rappedfire_im = CreateImage(6,24,4)
SetBuffer ImageBuffer(rappedfire_im,frame)
midx = ImageWidth(rappedfire_im)/2
midy = ImageHeight(rappedfire_im)/2

Color 255,0,0
Line midx,0,midx,24
Color 170,0,20
Line midx-1,0,midx-1,24
Color 170,0,20
Line midx+1,0,midx+1,24

Color 255,120,105
For i=0 To 4

Color 255,220,205
burnhole_y=Rnd(ImageHeight(rappedfire_im))
Plot midx,burnhole_y
Color 0,0,0
Plot midx,burnhole_y+1
Plot midx,burnhole_y+2


Next

;Color 0,0,0
;For i=0 To 10
;Plot midx,Rnd(ImageHeight(rappedfire_im))
;Next


For l=0 To 5
burnhole_y=Rnd(ImageHeight(rappedfire_im))
Color 0,0,0

Plot midx-1,burnhole_y
Plot midx+1,burnhole_y

Plot midx+1,burnhole_y-1
Plot midx+1,burnhole_y+1


Next
;+++ sparkly head of rapedfire bullet
For l = 0 To 20
Color Rnd(100,200),Rnd(100,200),0
;Color 255,255,0
Plot midx+Rnd(-4,4),midy - (ImageHeight(rappedfire_im)/2) + Rnd(-6,6)

Next
For l = 0 To 40
Color Rnd(200,255),Rnd(200,255),Rnd(100,255)
;Color 255,255,0
Plot midx+Rnd(-3,3),midy - (ImageHeight(rappedfire_im)/2) + Rnd(-3,3)

Next
Next


End Function


Function Make_Quazar() ;energy star bullets
For frame = 0 To 15

SetBuffer ImageBuffer(Quazar_im,frame)
;ResizeImage Quazar_im,24,24
midx = ImageWidth(Quazar_im)/2;+Rnd(-3,3)
midy = ImageHeight(Quazar_im)/2;+Rnd(-3,3)


;TFormFilter


;Color 255,0,0

For l = 0 To 200
;Plot Rnd(ImageWidth(Quazar_im)),Rnd(ImageHeight(Quazar_im))
Color Rnd(225,255),Rnd(225,255),Rnd(0,25)
;Color 255,255,0
;Color 0,255,0


;Line midx,midy,Rnd(-(midx+fr),midx+frame),Rnd(-(midy+frame),midy+frame)
Line midx,midy,Rnd(midx-10,midx+10),Rnd(midy-10,midy+10)
;Color 255,255,250


;Line midx,midy,Rnd(-(midx+fr),midx+frame),Rnd(-(midy+frame),midy+frame)
;Line midx,midy,Rnd(midx-10,midx+10),Rnd(midy-10,midy+10)


;Color 205,205,255
;Plot midx+Rnd(-1,1),midy+Rnd(-1,1)

Next
For l = 0 To 10
;Plot Rnd(ImageWidth(Quazar_im)),Rnd(ImageHeight(Quazar_im))
Color Rnd(25,255),Rnd(25,255),Rnd(205,255)
;Color 255,255,0
Line midx,midy,Rnd(midx-15,midx+15),Rnd(midy-15,midy+15)


;Line midx,midy,Rnd((midx-frame),(midx+frame)),Rnd(-(midy+frame),(midy+frame))
;Color 205,205,255
;Plot midx+Rnd(-1,1),midy+Rnd(-1,1)

Next


For l = 0 To 60
;Plot Rnd(ImageWidth(Quazar_im)),Rnd(ImageHeight(Quazar_im))
;Color Rnd(5,255),Rnd(5,255),Rnd(205,255)
Color 0,0,0
Line midx,midy,Rnd(midx-5,midx+5),Rnd(midy-5,midy+5)
If l=>30 Then
Line midx,midy,Rnd(midx-8,midx+8),Rnd(midy-8,midy+8)
EndIf
If l=>40 Then
Line midx,midy,Rnd(midx-15,midx+15),Rnd(midy-15,midy+15)
EndIf

;Line midx,midy,Rnd(midx-10,midx+10),Rnd(midy-1,midy+1)
;Line midx,midy,Rnd(midx-2,midx+2),Rnd(midy-10,midy+10)
;Line midx,midy,Rnd(midx-10,midx+10),Rnd(midy-1,midy+1)

;Line midx+l,midy+l,Rnd(midx-10,midx+10),Rnd(midy-10,midy+10)
;Line midx-l,midy-l,Rnd(midx-10,midx+10),Rnd(midy-10,midy+10)


;Line midx,midy,Rnd(-(midx+frame),midx+frame),Rnd(-(midy+frame),midy+frame)
;Color 205,205,255
;Plot midx+Rnd(-1,1),midy+Rnd(-1,1)

Next


;center
funct_used = funct_used+1
Color 200+frame*3,200+frame*3,200+frame*3
Color 255,200,200
Plot midx,midy+1
Plot midx+1,midy
Plot midx-1,midy
Plot midx,midy-1
Color 20+frame*10,255+frame*10,255
Color 255,0,0
;lite rays******************************************************
Plot midx+frame,midy
Plot midx+frame/2,midy


Plot midx,midy+frame
Plot midx,midy+frame/2
;Color 255,255,255
Plot midx,midy-frame
Plot midx,midy-frame/2


Plot midx-frame,midy
Plot midx-frame/2,midy

;diagonals
Color 20,20,255
Color 255,0,0
Plot midx+frame,midy+frame
Plot midx-frame,midy-frame
Plot midx-frame,midy+frame
Plot midx+frame,midy-frame
Color 20,20,255
Color 255,0,0
Plot midx+frame/2,midy-frame/2;tn
Plot midx+frame/2,midy+frame/2;to
Plot midx-frame/2,midy-frame/2;th
Plot midx-frame/2,midy+frame/2;th
Plot midx+frame/3,midy
Plot midx+frame/4,midy
Plot midx,midy+frame/3
Plot midx,midy+frame/4
Plot midx,midy-frame/3
Plot midx,midy-frame/4
Plot midx-frame/3,midy
Plot midx-frame/4,midy
;diagonals end
;Color 255,255,255



;endof lite rays*********************

;MaskingMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
Color 0,0,0
;Oval midx,midy,3+frame,3+frame,1
;Oval midx-4+frame,midy-4+frame,9-frame,9-frame,1
Oval -4,-4,ImageWidth(Quazar_im)+8,ImageHeight(Quazar_im)+8,0
Oval -3,-3,ImageWidth(Quazar_im)+6,ImageHeight(Quazar_im)+6,0
Oval -2,-2,ImageWidth(Quazar_im)+4,ImageHeight(Quazar_im)+4,0
Oval -1,-1,ImageWidth(Quazar_im)+2,ImageHeight(Quazar_im)+2,0
;Oval 0,0,ImageWidth(Quazar_im),ImageHeight(Quazar_im),0
;Oval 0,0,ImageWidth(Quazar_im),ImageHeight(Quazar_im),0

Oval -5,-5,10,10,1
Oval ImageWidth(Quazar_im)-5,-5,10,10,1
Oval midx+5,midy+5,10,10,1
Oval -5,midy+5,10,10,1
;MaskingMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
;For l= 0 To 1
;Color Rnd(255),Rnd(255),Rnd(255)
;Plot midx+Rnd(-1,1),midy+Rnd(-1,1)
;Next
;DebugLog frame
;SetBuffer ImageBuffer(Quazar_im,frame)

;ResizeImage Quazar_im,frame,frame
;


Next
For f = 1 To 15 Step 4

SetBuffer ImageBuffer(Quazar_im,f)
angle# = f
;ResizeImage Quazar_im,10.0*f,10.0*f
RotateImage Quazar_im,angle#

Next

;For f = 0 To 15
;SetBuffer ImageBuffer(Quazar_im,f)
;DrawImage (Quazar_im,frame,frame,frame-1)
;ResizeImage Quazar_im,170.0,170.0

;Next
;For f = 11 To 15
;SetBuffer ImageBuffer(Quazar_im,f)

;ResizeImage Quazar_im,100.0,100.0

;Next




End Function

;BULLET********************BULLETS*********************BULLETS****************************BULLETS

Function Make_Ufo_im()
ufo_im = CreateImage(100,100)
;Color 0,255,0
SetBuffer ImageBuffer(ufo_im)
;rockets
For i = 1 To 3
Color 75-(10*i),75,75-(10*i)
Line 25+i,60,25+i,95-(i*5) ;left rocket
Line 25-i,60,25-i,95-(i*5)
Line 75+i,60,75+i,95-(i*5) ;right rocket
Line 75-i,60,75-i,95-(i*5)
Next
Line 25,60,25,70
Line 75,60,75,70
Color 175,75,75
Line 25,65,25,95
Line 75,65,75,95
;mid section
For i = 1 To 4 ;neck
Color 40,80,40
Line 50+i,20+(i*7),50+i,100-(i*7)
Line 50-i,20+(i*7),50-i,100-(i*7)
Next
For i = 1 To 4 ;neck highlight
Color 70,100,70
Line 50+i,20+(i*7),50+i,90-(i*7)
Line 50-i,20+(i*7),50-i,90-(i*7)
Next
For i = 1 To 3
Line 50+i,0+(i*10),50+i,60
Line 50-i,0+(i*10),50-i,60
Next

;wings
For i = 1 To 25
Color 55+i,75+(i*2),25+i
Line 50-i,40+i,50-i,60+i
Line 50+i,40+i,50+i,60+i
Next
;wing tips
Line 75,65,75,84
Line 25,65,25,84
For i = 1 To 25
;Color 125-i,150-i,125-i
Color 80-i,130-(i*3),50-i
Line 75+i,65-i,75+i,85-Ceil(i*1.75)
Line 25-i,65-i,25-i,85-Ceil(i*1.75)
Next
;head
Color 30,80,30
For i = 1 To 10
Line 50+Ceil(i/2),100-i,50-Ceil(i/2),100-i ;forhead
Next
For i = 1 To 5
Line 45+i,90-i,55-i,90-i
Next
Color 25,25,25
For i = 1 To 5
Line 50+Ceil(i/2),97-i,50-Ceil(i/2),97-i ;forhead
Next
Color 175,75,75
Line 50,0,50,10
;center body and rocket centers
Color 50,70,20
Line 50,38,50,63 ;wings center line
Color 70,90,70
Line 50,10,50,86
For i = 1 To 75 Step 6
Color 175-i,75-i,75-i
Plot 50,0+i
Next
Color 70,90,70
Line 51,56,75,80
Line 49,56,25,80
Line 90,55,75,80
Line 10,55,25,80

ScaleImage ufo_im,.5,.25
RotateImage ufo_im,90
End Function

Function SpaceyText(x,y,message$,centre)
If Len(message)>0 Then
If centre = True Then
length = Len(message) * ImageWidth(spaceyfont(0))
xs = (640-length)/2
Else
xs = x
End If

For c = 1 To Len(message)
v = 0
ch$ = Mid$(Upper(message), c, 1)
If ch>="0" And ch<="9" Then
v = 26 + Asc(ch)-48
Else If ch>="A" And ch<="Z" Then
v = Asc(ch)-65
Else
v = 36
End If

DrawImage spaceyfont(v),xs + (c * ImageWidth(spaceyfont(0))), y
Next
End If
End Function

Function Make_Bonus_Images()
Bonus_im = CreateImage(64,16,8)
For i = 0 To 7
SetBuffer ImageBuffer(bonus_im,i)
ClsColor i Shl 5,0,0
Cls
Color 64,192,64
Rect 0,0,64,16,False
Text 8,2,"BONUS"
SetBuffer BackBuffer()
Next
End Function

Function Move_Bonus_Item()
If bonus\active = True Then
bonus\y = bonus\y + 4
If MilliSecs() > bonus\frametimer + 100 Then
bonus\frame = (bonus\frame + 1) And 7
bonus\frametimer = MilliSecs()
End If
DrawImage bonus_im,bonus\x, bonus\y, bonus\frame
If ImagesCollide(bonus_im, bonus\x,bonus\y,0, ship_im, player\x, player\y,0) Then
bonus\active = False
Choose_Bonus_Type
End If
If bonus\y > 600 Then bonus\active = False
End If
End Function

Function Choose_Bonus_Type()
bt = Int(Rand(6))+1
Select bt
Case 1
; Shield
player\Shield_Active = True
player\Shield_Timer = MilliSecs()
Case 2
; Non-expiring shot
Player\Non_Expiring_Shot = True
Player\Nes_Timer = MilliSecs()
Case 3
; Speed
Player\Speedy = True
Player\Speedy_Timer = MilliSecs()
control\Player_speed = control\Player_StartSpeed Shl 2
Case 4
; Cluster fock
Player\cluster = True
Player\Cluster_timer = MilliSecs()
Case 5
; Rebuild bases
Make_Bases
Case 6
player\lives = player\lives + 1
; Extra Life
End Select

End Function

;Becky Roses wierd way of doing sound in code
.shoot
Data 4810
Data 82,73,70,70,194,18,0,0,87,65,86,69,102,109,116,32,18,0,0,0,1,0,1,0,64,31,0,0,64,31,0,0,1,0,8,0,0,0,102,97,99,116,4,0,0,0,143,18,0,0,100,97,116,97,143,18,0,0,126,163,97,101,124,137
Data 134,110,112,120,154,131,117,116,152,132,141,155,80,104,221,66,135,200,59,112,244,129,56,188,155,61,114,208,47,88,198,89,59,162,204,46,109,207,113,84,189,194,40,111,234,125,51,146,215,68,72,202,156,43,97,207,127,88,109,205,90,93,121,204
Data 89,87,127,220,84,85,133,211,84,93,122,200,88,79,115,193,116,70,94,177,164,64,73,160,214,61,60,138,207,126,54,95,161,210,79,49,135,199,148,77,76,136,210,159,38,91,170,192,141,58,107,136,197,143,41,83,146,209,145,64,80,142,186,199
Data 100,63,121,150,205,143,43,88,142,180,188,82,41,95,163,199,191,92,57,113,153,184,181,81,41,112,145,183,205,113,36,104,128,162,203,152,73,60,117,143,182,191,129,45,52,118,160,178,185,153,48,51,131,139,168,193,153,93,44,89,148,152,172,188
Data 140,73,48,100,144,161,171,191,160,88,41,78,136,159,155,183,182,149,69,43,93,139,153,155,183,178,163,88,36,81,114,155,158,155,179,172,146,76,43,50,121,155,159,164,160,170,169,142,78,38,52,103,151,166,159,157,160,166,160,140,83,38,55,82
Data 142,165,162,163,147,154,165,154,145,114,55,44,53,103,148,168,169,161,155,145,145,156,151,144,125,106,60,49,58,85,134,156,174,171,161,158,145,140,136,143,148,140,132,119,116,34,28,111,226,100,125,185,106,178,115,102,160,91,132,162,107,188,85,106
Data 102,96,186,91,163,121,92,179,86,150,130,92,163,88,155,126,92,153,87,174,104,146,124,92,194,87,180,92,98,100,95,198,79,201,79,126,144,121,152,88,192,88,195,83,112,81,113,151,87,147,90,201,82,204,82,144,112,97,101,100,177,86,157,89
Data 203,83,198,84,178,91,195,86,142,107,170,93,118,130,147,103,109,147,135,111,103,156,125,107,92,154,115,109,99,149,92,104,107,136,98,99,122,113,105,90,144,98,127,85,187,90,168,87,207,85,210,97,160,94,171,119,104,118,110,188,86,184,86,184
Data 88,179,89,106,120,101,124,96,203,84,207,87,126,106,111,114,86,200,85,205,101,118,113,86,201,83,203,103,106,121,97,204,86,174,92,97,164,90,205,98,120,114,100,161,88,163,97,115,199,85,197,93,101,174,90,209,108,106,163,90,147,106,104,157
Data 81,134,102,100,199,88,122,121,84,173,97,110,210,88,134,113,89,177,101,109,171,89,121,132,95,142,113,100,212,101,106,198,86,110,177,86,157,158,86,168,101,88,170,98,102,171,97,104,208,98,100,210,85,101,209,92,112,192,92,107,208,85,102,207
Data 87,110,179,95,104,205,116,95,169,105,87,134,135,91,117,197,83,121,203,92,105,203,121,92,143,128,84,118,204,82,103,172,106,99,153,189,82,119,209,106,99,147,126,78,112,203,84,88,129,162,84,106,171,107,94,124,210,86,108,130,189,83,117,144
Data 146,87,124,164,117,90,129,185,105,93,129,202,96,97,131,203,96,97,130,206,100,94,126,210,108,90,125,196,135,81,121,166,182,75,113,143,211,85,101,131,169,115,85,122,137,195,78,105,126,176,109,85,123,136,208,79,103,124,150,158,79,103,130,176
Data 116,76,112,135,193,152,77,116,137,159,142,77,114,129,156,155,73,101,132,144,192,87,91,127,140,205,126,72,112,131,137,194,70,98,122,137,168,131,69,102,133,140,162,148,73,114,130,140,172,135,72,99,131,141,143,201,70,96,122,139,140,193,153,67
Data 107,133,140,138,195,85,80,112,134,141,139,184,98,74,118,132,139,138,175,169,64,100,132,140,141,135,189,135,67,108,132,138,139,136,176,159,62,99,129,138,139,138,142,184,105,71,114,137,140,141,135,135,167,131,67,107,128,140,138,136,136,133,172,109
Data 65,98,129,140,140,138,134,134,132,167,116,65,94,130,137,134,132,129,128,127,133,159,132,64,99,123,140,141,137,138,134,130,129,129,134,163,117,65,90,128,140,141,139,136,133,133,129,130,127,127,127,144,156,119,63,94,130,141,143,131,120,121,123,130
Data 115,113,115,119,121,113,112,114,130,119,118,118,139,127,125,126,139,122,124,121,132,118,121,115,140,126,124,126,129,118,118,114,124,122,136,127,121,120,128,124,115,132,119,146,118,125,118,143,125,147,126,136,120,145,116,126,125,121,131,112,132,113,157,124
Data 145,121,141,132,133,122,119,130,126,121,115,162,111,129,157,116,99,141,114,93,156,134,124,119,166,105,113,167,126,113,138,161,105,124,157,110,115,147,154,100,112,153,97,122,135,155,95,136,154,112,108,138,159,101,105,153,144,121,111,166,141,96,120,148
Data 139,98,115,161,131,109,124,158,151,95,137,155,143,105,109,170,150,98,108,137,169,107,97,134,155,134,96,119,159,150,111,108,133,173,129,95,126,132,166,116,93,132,148,143,96,98,129,154,143,118,96,128,158,150,112,104,129,153,154,111,108,125,142,162
Data 124,111,104,126,168,134,102,103,119,147,158,131,98,109,124,150,158,121,100,109,132,158,159,128,101,111,125,155,158,129,113,98,122,146,152,151,115,96,115,136,144,154,139,111,92,119,137,142,159,141,100,99,105,132,145,148,150,128,91,96,127,136,143,153
Data 146,111,95,104,127,139,149,152,148,128,92,92,123,137,139,149,156,141,110,90,99,123,138,140,144,147,145,116,96,98,115,135,138,141,147,147,150,123,94,93,106,129,140,142,139,147,150,139,126,94,94,109,133,142,144,141,142,149,144,135,114,100,90,102
Data 130,138,144,143,137,136,138,139,136,127,110,91,93,103,124,142,145,145,142,136,135,136,140,138,128,125,108,96,94,105,120,137,147,149,145,142,137,133,132,133,136,135,130,126,123,93,77,99,157,122,145,121,124,143,119,135,131,117,141,113,126,141,120,141
Data 115,121,124,117,141,119,119,130,115,138,122,132,131,116,140,112,134,128,117,136,114,138,119,134,125,117,144,115,144,114,122,116,120,145,111,145,111,132,127,131,128,117,147,116,146,110,130,127,131,126,118,147,119,147,112,138,113,141,115,125,113,127,129,118
Data 123,120,143,114,138,116,148,113,146,113,144,114,148,113,140,116,146,114,137,118,126,113,134,115,122,111,130,116,124,112,135,116,128,113,139,115,134,114,146,114,140,115,150,114,148,118,143,116,148,125,127,123,131,135,115,133,116,149,114,149,113,148,117,137
Data 118,136,132,117,133,115,148,113,149,113,125,125,121,145,113,148,113,132,121,125,125,114,148,113,149,121,122,127,116,150,114,147,116,135,135,115,145,114,133,123,120,132,114,148,117,132,139,114,151,114,120,132,116,148,119,126,129,117,149,117,127,128,114,148
Data 114,123,144,111,144,118,115,150,113,136,124,115,151,117,124,151,115,137,125,115,149,118,121,153,115,127,131,114,135,126,116,143,122,118,149,119,119,146,113,119,143,113,135,142,113,136,125,116,135,125,114,152,126,115,150,120,115,145,122,117,137,125,115,149
Data 131,113,139,123,113,129,133,114,122,144,113,125,154,115,119,154,122,116,148,121,113,128,135,113,128,153,114,120,155,125,115,138,129,113,123,153,114,116,140,128,114,123,156,113,117,131,130,111,124,153,117,116,138,148,112,122,154,132,113,125,154,122,115,130
Data 144,112,117,136,134,112,120,143,128,113,122,146,125,113,122,147,125,113,121,145,126,112,121,139,131,111,118,133,141,110,116,128,153,111,113,127,156,119,111,123,139,134,110,117,129,155,113,112,124,142,131,110,117,129,157,127,110,123,134,156,115,114,126,133
Data 152,111,117,125,137,146,109,113,127,137,142,113,114,126,136,147,115,113,127,133,153,122,110,124,130,142,137,106,111,125,130,154,124,107,121,130,133,155,110,113,124,132,139,145,112,111,126,132,135,155,111,112,123,131,134,156,113,107,121,131,133,139,145,106
Data 114,124,131,132,151,137,105,116,128,132,133,147,127,105,113,127,132,132,135,148,107,106,122,131,133,132,140,139,104,109,124,131,132,131,136,145,105,111,122,131,132,132,131,145,128,104,112,126,132,133,132,131,141,136,109,109,124,132,133,133,131,130,137,142
Data 106,111,122,130,133,132,132,130,130,142,130,106,109,125,131,131,130,129,128,128,127,138,135,110,106,122,131,134,133,132,131,130,128,128,129,137,139,107,108,119,130,133,133,133,132,130,129,128,127,127,127,133,139,129,104,109,121,131,134,135,128,136,126,131
Data 126,133,124,127,125,130,122,125,123,127,124,125,123,126,125,127,123,128,125,127,124,128,124,125,128,125,125,127,126,130,124,126,125,127,123,128,125,134,124,129,126,131,125,133,126,132,126,131,127,128,127,128,130,124,126,126,131,125,131,122,130,127,135,126
Data 131,127,131,129,128,130,123,129,128,129,118,137,123,118,133,127,113,124,144,112,133,144,122,121,144,134,113,142,132,117,125,144,119,112,140,127,119,134,141,116,117,143,131,120,128,142,122,115,139,127,121,120,142,121,114,132,139,122,117,131,141,114,120,136
Data 136,116,118,140,135,116,118,134,142,113,124,136,139,118,116,130,143,117,116,125,143,124,112,123,137,135,113,113,134,143,121,114,121,144,134,118,120,128,146,135,112,124,136,143,131,112,122,137,144,125,111,124,140,142,123,114,120,137,145,125,115,117,133,147
Data 138,114,115,125,137,140,120,113,116,130,145,134,118,114,122,137,147,135,114,115,121,136,146,132,120,113,123,139,145,140,123,110,121,132,140,143,127,112,113,129,135,141,146,123,108,117,126,135,145,142,126,111,112,123,134,139,141,134,113,108,122,129,135,141
Data 140,130,110,112,124,132,137,141,141,130,114,106,120,131,134,138,143,138,128,111,109,121,129,136,137,139,141,130,113,108,113,126,133,136,136,140,140,128,116,106,112,125,134,136,135,138,139,138,129,111,107,109,124,134,138,136,134,138,137,136,128,114,106,108
Data 120,132,137,137,135,133,134,135,133,129,120,111,107,111,123,131,137,138,137,133,133,132,135,134,131,127,118,110,107,111,120,131,136,139,138,137,135,133,130,131,132,132,130,127,126,118,101,107,124,134,135,125,133,127,126,132,123,129,131,122,129,122,126,132
Data 121,132,124,124,133,122,132,126,124,130,122,131,126,130,130,122,132,121,131,128,123,130,121,132,124,131,126,124,134,123,133,121,127,122,126,132,121,131,121,131,125,125,125,125,134,120,134,120,131,124,131,124,126,133,127,132,122,134,123,134,121,130,121,132
Data 123,127,122,128,129,124,126,126,133,122,135,124,135,122,134,123,135,122,134,123,135,121,133,121,133,119,130,120,134,120,133,122,135,121,134,123,135,122,136,125,134,123,136,127,129,126,131,130,124,129,125,128,121,133,121,132,122,136,122,136,126,129,125,128
Data 132,121,132,122,135,122,135,127,125,127,124,135,122,136,122,129,126,126,127,121,135,121,136,122,126,127,123,130,121,136,122,133,130,122,133,121,133,125,127,129,122,137,123,134,131,122,135,122,129,128,122,132,123,132,126,125,137,122,134,125,122,136,122,134
Data 124,120,135,121,131,132,121,137,122,122,135,122,135,131,122,138,123,122,136,122,134,132,122,137,124,122,138,123,128,136,122,131,128,122,134,127,122,137,125,122,137,121,122,136,121,128,136,121,128,130,121,126,131,121,126,133,121,132,135,121,129,130,121,125
Data 133,121,123,136,121,126,138,122,123,137,125,121,139,124,122,133,129,121,134,135,121,125,135,123,122,139,123,121,132,130,121,124,139,122,123,135,129,121,131,138,122,124,141,129,119,127,133,121,121,137,126,120,124,139,122,123,130,134,121,124,136,129,121,127
Data 140,125,121,130,141,123,122,132,139,122,122,134,138,121,123,135,138,121,122,133,138,121,122,131,140,121,121,129,141,124,120,126,141,127,119,125,139,135,119,123,131,141,122,120,127,136,130,119,124,128,140,121,120,125,135,132,119,121,127,141,125,119,123,129
Data 141,127,119,124,131,140,125,119,125,131,141,124,119,125,129,141,125,118,123,129,139,130,119,121,128,134,142,122,117,124,127,136,130,117,119,127,130,142,130,117,123,129,131,142,124,118,125,129,131,142,123,117,123,129,131,137,133,117,122,126,130,133,139,124
Data 116,124,129,130,134,136,117,117,124,129,131,133,139,118,118,123,128,130,131,139,126,116,122,129,130,131,133,136,122,116,123,129,130,130,131,138,125,115,122,128,130,130,130,135,137,118,117,125,129,130,130,130,131,138,121,116,121,128,130,131,130,129,132,137
Data 119,115,122,128,130,131,130,129,129,132,137,119,116,121,128,130,129,129,128,128,127,129,136,122,115,119,127,131,131,130,130,129,128,128,128,132,135,120,114,120,128,131,131,131,130,129,129,128,128,127,127,128,133,131,121,114,121,128,130,136,129,131,127,129
Data 127,130,127,129,126,129,127,129,126,128,126,129,126,127,126,128,126,128,126,129,126,128,126,129,125,127,126,128,126,129,126,130,126,128,127,128,126,130,127,129,127,129,128,127,127,129,128,126,128,127,127,126,129,126,128,126,129,127,129,127,130,128,130,128
Data 127,128,128,128,126,129,126,127,126,128,123,125,130,122,129,133,124,124,136,125,122,135,127,124,130,133,121,132,135,124,125,135,129,120,132,130,123,124,134,124,121,133,132,123,123,134,127,120,128,134,124,123,130,133,121,127,134,129,122,127,137,127,123,130
Data 133,128,122,131,133,125,122,129,136,126,120,130,135,128,121,126,136,129,122,125,134,135,122,123,131,135,126,119,128,135,130,122,123,128,137,125,122,125,134,134,121,123,127,135,132,120,120,131,137,129,121,121,132,136,132,122,122,130,137,133,122,121,126,136
Data 135,123,121,122,130,135,131,120,120,127,134,136,125,120,121,129,137,134,122,119,122,131,137,136,125,119,123,128,135,136,127,119,120,128,134,137,134,121,118,123,129,134,138,132,120,120,125,129,135,137,129,121,116,123,129,132,136,133,122,116,119,127,131,134
Data 136,131,120,118,121,127,132,135,136,133,122,116,118,126,131,133,135,136,130,120,116,119,127,132,132,134,136,131,125,116,118,125,130,133,133,134,135,132,123,116,117,122,129,132,132,133,134,134,130,123,116,116,123,128,133,133,132,133,134,133,129,124,117,115
Data 121,127,132,133,132,131,131,132,131,129,126,119,115,117,121,128,133,134,133,132,131,130,131,131,130,128,125,119,116,117,119,126,131,134,134,133,132,131,130,129,130,130,130,128,127,124,117,112,122,131,131,129,130,127,127,128,126,129,128,128,129,125,127,126
Data 126,129,125,129,127,126,129,125,129,127,126,128,125,129,127,128,128,125,129,125,129,127,125,128,125,129,126,127,127,126,130,124,130,125,128,128,127,129,125,130,125,129,126,127,126,127,129,125,129,125,129,125,130,125,128,128,128,128,126,130,126,130,125,130
Data 125,130,125,129,127,129,126,128,129,128,127,127,130,128,129,126,130,127,129,126,131,127,130,125,129,126,129,125,130,126,129,126,130,127,129,126,130,128,128,127,129,127,126,129,127,128,125,130,125,129,125,131,125,130,126,130,126,127,128,127,128,125,130,125
Data 130,125,130,126,130,128,126,128,125,130,125,130,125,131,127,127,128,126,130,125,131,125,127,128,126,129,125,131,125,130,128,125,130,125,130,126,128,127,125,131,125,131,128,125,130,125,130,127,127,129,125,131,126,128,128,125,132,126,129,130,125,131,126,125
Data 130,124,130,127,124,130,124,127,128,124,131,127,126,130,125,128,129,125,132,127,126,131,125,127,129,125,132,126,125,132,126,128,132,125,129,129,125,130,128,124,130,128,124,132,127,124,132,125,124,132,125,126,132,125,125,131,126,125,132,125,125,132,125,125
Data 132,126,125,132,125,124,132,126,124,130,128,124,131,130,124,128,130,125,125,132,125,124,132,127,124,129,130,124,128,133,125,125,133,128,124,130,130,125,125,133,126,124,129,130,124,126,132,126,123,130,131,124,125,133,129,124,127,132,126,124,130,130,125,125
Data 133,128,124,125,134,127,124,126,134,126,124,126,133,125,124,127,134,125,124,126,133,125,124,126,134,126,123,125,133,127,123,125,131,130,123,124,129,133,124,123,126,134,127,123,125,131,131,125,124,127,134,129,123,125,130,134,125,123,126,133,132,124,124,128
Data 133,130,123,125,127,134,128,123,124,128,134,128,123,124,127,134,132,123,124,128,130,134,125,123,126,129,135,127,122,123,127,131,134,124,122,126,129,132,131,123,124,126,129,135,128,123,124,127,129,133,131,123,124,126,129,132,132,125,122,126,128,129,134,128
Data 122,123,127,129,131,134,126,121,125,127,129,130,134,124,121,124,127,129,129,133,129,121,122,126,129,129,129,134,127,121,123,127,129,129,129,133,128,121,122,126,128,129,129,130,133,124,121,123,127,129,129,129,129,133,126,122,123,127,129,129,129,129,130,132
Data 128,121,123,126,129,129,129,129,129,130,133,128,121,123,127,128,129,128,128,128,128,128,132,129,121,122,126,129,129,129,129,129,128,128,128,129,132,128,121,122,125,129,130,130,129,129,128,128,128,128,127,128,129,131,126,120,121,126,129,132,130,128,128,128
Data 128,127,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,127,127,128,127,128,127,128,127,127,128,128,127,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,128,128,127,128,128,127,128
Data 127,129,127,128,127,128,128,127,127,127,127,126,129,126,126,130,127,125,129,128,124,130,130,126,128,131,127,126,131,127,125,129,129,124,126,131,126,125,129,130,124,129,131,126,125,130,130,124,126,131,128,125,128,131,125,124,130,129,125,125,131,129,125,126
Data 130,129,124,125,131,128,124,126,131,129,124,126,131,129,124,124,131,130,125,124,128,132,126,123,127,131,128,124,125,131,130,125,124,127,133,128,124,125,130,132,128,123,126,131,132,126,123,128,131,131,125,124,126,132,131,125,124,126,132,132,127,124,126,131
Data 133,129,124,124,126,132,130,124,123,125,130,133,128,124,123,127,132,133,128,123,124,127,131,133,128,124,124,127,131,133,130,124,123,125,129,132,132,128,123,124,128,130,132,131,125,122,124,128,131,133,131,125,121,124,126,130,132,131,128,122,122,126,128,130
Data 133,131,127,122,123,127,129,131,132,131,128,122,121,126,128,130,132,132,131,126,122,122,126,128,130,131,132,132,127,122,121,123,127,130,130,131,132,131,126,123,121,123,127,129,130,130,131,132,130,126,121,120,122,127,130,131,130,130,131,131,130,126,122,120
Data 121,126,129,131,131,130,130,130,130,129,127,124,121,120,123,127,129,131,131,131,130,129,130,130,130,128,127,123,122,121,122,126,128,131,132,131,131,130,129,129,129,129,129,128,127,127,122,119,123,128,128,129,129,128,129,128,127,128,127,128,128,127,128,126
Data 127,127,127,128,127,128,127,127,128,126,128,127,127,128,127,128,127,127,128,127,128,127,128,127,127,128,127,128,127,127,127,127,128,126,128,126,128,128,128,128,127,128,127,128,126,128,126,128,128,127,128,127,128,126,128,126,128,127,127,127,127,128,127,128
Data 127,128,126,128,126,128,127,129,127,128,127,128,127,128,128,128,127,128,128,128,127,128,128,128,127,127,127,127,127,127,128,127,127,128,128,127,127,128,127,128,127,128,127,128,127,129,127,128,127,129,127,128,127,128,127,127,128,127,128,127,129,127,128,127
Data 128,127,128,127,127,128,127,128,126,128,127,128,128,127,128,127,129,127,128,127,127,128,127,128,127,128,127,128,128,127,128,126,128,127,128,127,126,129,127,129,128,127,128,127,129,127,128,128,127,129,127,128,127,127,129,127,129,128,127,129,127,128,128,127
Data 128,127,127,128,126,128,127,127,128,127,128,128,127,129,127,127,128,127,128,128,127,129,127,127,128,127,127,128,127,129,128,127,129,127,127,129,127,128,129,127,128,128,127,128,128,126,128,128,126,129,128,126,129,127,126,129,128,127,129,128,127,129,127,126
Data 128,127,126,128,128,126,128,128,127,128,128,127,127,129,127,127,129,127,127,128,128,127,128,128,127,127,128,127,127,129,127,127,128,128,127,128,129,127,127,129,128,127,128,129,127,126,128,127,126,127,129,127,126,128,128,127,127,129,128,127,127,129,127,127
Data 128,129,127,127,128,128,127,127,128,128,127,127,129,128,127,127,129,128,127,127,129,128,127,127,129,128,127,127,128,129,127,127,128,129,127,127,127,129,128,127,127,128,128,127,127,127,129,127,127,127,128,128,127,127,127,129,127,127,127,128,129,127,127,127
Data 128,128,127,127,127,129,129,127,127,127,128,128,127,127,127,128,129,127,127,127,128,129,128,127,127,128,129,128,127,127,127,128,129,127,127,127,127,128,128,127,127,127,128,128,128,127,127,127,128,128,128,127,127,127,128,128,129,127,127,127,127,128,128,128
Data 127,127,127,128,128,128,128,127,127,127,128,128,128,128,127,127,127,128,128,128,128,127,127,127,127,128,128,128,128,127,127,127,128,128,128,128,128,127,127,127,127,128,128,128,128,128,127,127,127,128,128,128,128,128,128,127,127,127,128,128,128,128,128,128
Data 128,127,127,127,128,128,128,128,128,128,128,128,127,127,127,128,128,128,128,128,128,128,128,128,127,127,127,127,128,128,128,128,128,128,128,128,128,128,127,127,127,128,128,128,128,128,128,128,128,128,127,128,128,128,128,127,127,127,128,128,128,128,128,127
Data 128,127,128,128,128,128,128,128,128,0

.makeSound
Restore shoot
Read ln
pos=0

Repeat
fileName$="C:\sound"+Rnd(1,1000)+".wav"


Until FileType(fileName)=0

fileOut=WriteFile(fileName)
For pos=0 To ln-1
Read bt
WriteByte fileOut,bt
Next
CloseFile fileOut

Global shootSound=LoadSound(fileName)
;chnsound=PlaySound ( shootSound )
;ChannelPitch chnsound,4000
;Delay 1000
;thirdsound=PlaySound ( shootSound )
;ChannelPitch thirdsound,5000
;Delay 1000
;fourthsound=PlaySound ( shootSound )
;ChannelPitch fourthsound,9000


;Global chnsound=PlaySound(shootSound)
;ChannelPitch chnsound,4200


DeleteFile fileName
Return

















Function Do_Turret_array(im1,im2,im3)

For turret_index = 1 To Total_num_turrets
For frame = 0 To Turret_Rotations - 1
Select turret_index
Case 1
Turret_array_im(turret_index,frame) = CopyImage(im1)
Case 2
Turret_array_im(turret_index,frame) = CopyImage(im2)
Case 3
Turret_array_im(turret_index,frame) = CopyImage(im3)
Case 4
DebugLog "turret_index " + turret_index : WaitKey
Case 0
DebugLog "turret_index " + turret_index : WaitKey
End Select
;ResizeImage Turret_array_im(turret_index,frame),Rnd(20,30),Rnd(20,30)
RotateImage Turret_array_im(turret_index,frame),frame * 360/Turret_Rotations
Next
Next

End Function
;Make_Turret_type(midpoint\x,midpoint\y,1) ;The last variable of this function holds the index

Function Make_Turret_type(x,y,selected)
Player_Turret.PTurret_type = New PTurret_type
Player_Turret\x=x : Player_Turret\y=y : Player_Turret\ammo=100
Player_Turret\width=20 : Player_Turret\height=20
Player_Turret\iDir = 0 ;not sure if this is needed
Player_Turret\selected = selected
End Function

Function update_turret(x,y,selected);selected
For Player_Turret.PTurret_type = Each PTurret_type
Player_Turret\x = x : Player_Turret\y = y
Player_Turret\selected = selected
Player_Turret\ammo=100


;angle=ATan2( rotate\y+rotate\centery - MouseY(),rotate\x+ rotate\centerx - MouseX() )
angle=ATan2(Player_Turret\y - MouseY(),Player_Turret\x - MouseX() ) ; the angle between the curser and pointer

angle=angle-90 ; subtract 90 from the angle to compinsate for the blitz co-ord system
If angle>359 Then ; check angle is within 0-359 range
angle=angle-359 ; if not, wrap it round
ElseIf angle<0 Then
angle=angle+359
End If
Text 20,300,"angle? " + angle
;Line MouseX(),MouseY(),Player_Turret\x,Player_Turret\y
;player\iDir = angle
Player_Turret\frame = angle
Player_Turret\iDir = angle
If Player_Turret\selected > 3 Then
Player_Turret\equiped = 3
ElseIf Player_Turret\selected < 1 Then
Player_Turret\equiped = 1
Else
Player_Turret\equiped = Player_Turret\selected
EndIf
;DrawImage Turret_array_im(Player_Turret\equiped,Player_Turret\frame),MouseX(),MouseY()
DrawImage Turret_array_im(Player_Turret\equiped,Player_Turret\frame),Player_Turret\x,Player_Turret\y


Next
End Function

;Function Make_temppoint_im(temppoint_im)
;SetBuffer ImageBuffer(temppoint_im)
;midx=ImageWidth(temppoint_im)/2
;midy=ImageHeight(temppoint_im)/2

;Color 255,55,255
;Plot midx,midy

;SetBuffer BackBuffer()
;End Function

Function Make_T_bullet(bullet)
SetBuffer ImageBuffer(bullet)
Color 0,255,0
For i = 0 To 31
If i And 1 Then Plot 0,i Else Plot 5,i
Next
End Function

Function PrecomputeSinCosTables()
Local iAngle# = 0
; run through the full rotation cycle, and use Sin and Cos
; at 10-degree increments
For iAngle = 0 To numrotations-1
xSinTable#(iAngle) = -Sin(iAngle);the iAngle multiplyer corasponds to numrotations
yCosTable#(iAngle) = Cos(iAngle); the multiplyer * numrotations must = 360
;Print xSinTable#(iAngle)
;Print yCosTable#(iAngle)
;a = a + 1
Next
;Print "There are " + a + " precalculated angles in " + numrotations + " rotations"
;Delay 25000
End Function
Function LaunchBullet.TBullet(Player_X,Player_Y,iDir,selected)
; create a new Bullet instance
B.TBullet = New TBullet

; have it's starting point be the center of the player's ship


B\dX = Player_X
B\dY = Player_Y

; and have it face the same direction as the player
B\iDir = iDir ;set equal to player iDir

;B\iDir = angle
; give it a bit of a faster speed than the player
B\dSpeedModifier = 7 ;speed of bullet

; determine the player's speed amd create the bullet speed based on that
B\dSpeedX# = (xSinTable#(B\iDir)) * B\dSpeedModifier#
B\dSpeedY# = (yCosTable#(B\iDir)) * B\dSpeedModifier#

B\selected = selected


; increment the number of bullets fired for this level
iBulletsFired = iBulletsFired + 1
BulletsFired = BulletsFired + 1
End Function

;*************************************************************
; FUNCTION: UpdateBullets()
; This function keeps the bullets moving, checks if they've
; hit anything, and kills them if they go off-screen
;*************************************************************
Function UpdateBullets()
; go through all of the bullets
For B.TBullet = Each TBullet

;bullet ai
; update their x,y positions
B\dX# = B\dX# - B\dSpeedX#
B\dY# = B\dY# - B\dSpeedY#
; check there range ; remember to make a range field

;B\dx# = B\dx# + Rnd(-8,8)
;B\dY# = B\dY# + Rnd(-8,8)
; if the bullet is off the screen, or out of range or collides with a target, delete it, destroy = true

If B\dX < 0 Or B\dX > 800 Or B\dY < 0 Or B\dY > 600 Then
;Delete B
destroy = True



Else
destroy = False
EndIf









; otherwise, draw it
;delete the bullet or not? True or false, yes or no, no abla engalish, abla english
Select destroy
Case False
DrawImage Bullet_Image(B\selected,B\iDir),B\dX#,B\dY#
Case True

Delete B
If B = Null Then
destb = destb + 1
EndIf

End Select



Next


Text 50,500,"destroy " + destroy
Text 50,520,"destroyed bullets " + destb
Text 30,540,"BulletsFired " + BulletsFired

End Function



;______________________________________________________________________________________________________

Function get_picked(p) ;secondary wepon selection by keybourd input and mouse z speed
If KeyHit (2) p=1
If KeyHit (3) p=2
If KeyHit (4) p=3
If KeyHit (5) p=4
If KeyHit (6) p=5

If KeyDown (203)=True p=9
If KeyDown (205)=True p=10

Select MouseZSpeed()
Case 1
p=p+1
Case 0
mousepointer=p
Case -1
p=p-1
End Select
If p > Total_Num_Turrets Then p = (Total_Num_Turrets/Total_Num_Turrets) ;keep the player within the Turret index
If p < (Total_Num_Turrets/Total_Num_Turrets) Then p = Total_Num_Turrets
Return p
End Function

Function pick_pointer(p)
mousepointer = p
Select mousepointer
Case 1
update_target_point(blankimage,targetpointimage1)
Case 2
update_target_point(blankimage,targetpointimage2)
Case 3
update_target_point(blankimage,targetpointimage3)
Case 4
update_target_point(blankimage,targetpointimage4)
Case 5
update_target_point(blankimage,targetpointimage5)
Case 6
Case 7
Case 8
Case 9
update_target_point(gorightimage,blankimage)
Case 10
update_target_point(goleftimage,blankimage)
Default
update_target_point(idoltargetimage,blankimage)
End Select
Return p
End Function

Function Pick_A_Turret(picked)
For Player_Turret.PTurret_type = Each PTurret_type
Select Player_Turret\selected
Case 1
update_turret(player\x,player\y,Player_Turret\selected)
Case 2
update_turret(player\x,player\y,Player_Turret\selected)
Case 3
update_turret(player\x,player\y,Player_Turret\selected)
Default
update_turret(player\x,player\y,Player_Turret\selected)
End Select
Player_Turret\selected = picked
Next
End Function

Function Do_lazor_array(im1,im2,im3)
For lazor_index = 1 To total_num_lazors
For frame = 0 To numrotations - 1
Select lazor_index
Case 1
Bullet_Image(lazor_index,frame)=CopyImage(im1)
Case 2
Bullet_Image(lazor_index,frame)=CopyImage(im2)
Case 3
Bullet_Image(lazor_index,frame)=CopyImage(im3)
Case 4
DebugLog "lazor_index " + lazor_index : WaitKey
Case 0
DebugLog "lazor_index " + lazor_index : WaitKey
End Select
RotateImage Bullet_Image(lazor_index,frame),frame*360/numrotations
Next
Next
End Function


Function Make_green_lazor(b)
SetBuffer ImageBuffer(b)
Color 0,255,0
For i = 0 To 31
If i And 1 Then Plot 0,i Else Plot 5,i
Next
End Function

Function Make_yellow_lazor(b)
SetBuffer ImageBuffer(b)
Color 255,255,0
For i = 0 To 31
If i And 1 Then Plot 0,i Else Plot 5,i
Next
End Function

Function Make_purple_lazor(b)
SetBuffer ImageBuffer(b)
Color 255,0,255
For i = 0 To 31
If i And 1 Then Plot 0,i Else Plot 5,i
Next
End Function







Function Hud()
;display = (midpoint\y Sar 1)
;mousepoint\x=MouseX() : mousepoint\y=MouseY()
;Text midpoint\x , midpoint\y ,"graphics mid x = " + midpoint\x
;Text midpoint\x,midpoint\y + 10, "graphics mid y = " + midpoint\y

End Function
[codebox]


AJ00200(Posted 2009) [#95]
Is this project complete?
Are we going to put it up for download somewhere? (for free).
I can make the website.


SoggyP(Posted 2009) [#96]
Hello.

It is on a website. For free. Here. Enjoy.

Goodbye.


AJ00200(Posted 2009) [#97]
But not an exe file.
(and not that many people in the world have BB3D)

Ill Make a website for it.


Nike(Posted 2009) [#98]
That is a lot of code!!! lol
I made an exe for you AJ00200
it is at

www.theadventurescape.com/space.exe


Nike(Posted 2009) [#99]
O your making the website. Ok ill take it off mine then.


AJ00200(Posted 2009) [#100]
No, keep it on yours if you want.


Nike(Posted 2009) [#101]
Ok i will keep it on until i look at my ftp server sometime in the future, dont know what is is, and delete it.


Captain Wicker (crazy hillbilly)(Posted 2011) [#102]
I think we should start a new community project in 3d maybe. Just a thought.


SoggyP(Posted 2011) [#103]
Hello.

Go right ahead :)

Goodbye.


mk2y10(Posted 2012) [#104]
I know this forum is old, but it's sticky and SoggyP is a genius. Did you start that project Captain Wicker Soft?

I thing we should have community activities and such on the forum (and such :D )


psychicbottle(Posted 2012) [#105]
I vote some of us newbies make a kinda unrealistic but really simple Physics system. cant be thaaattt hard :D


LeftyGuitar(Posted 2014) [#106]
This is great. Really good to learn from. The graphics look amazing for being done all with code.