Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / DNG - Space Invaders

Author
Message
Libervurto
13
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 8th Aug 2010 20:34 Edited at: 21st Aug 2010 18:26
I'll start by just listing every thing that happens in Space Invaders then start to group these things and assign tasks.

- There are four defensive barriers that intercept fire from the player and aliens.
- The barriers are split into ten sections, each section can sustain three hits before being destroyed on the fourth hit.
- You start with 3 lives, every level you complete you gain a life.
- Only one bullet can be fired until it collides or goes off screen.

Graphics - Three types of alien and a mothership.
Graphics - Each alien has two animation frames.
Graphics - Enemy and player death has two animation frames.

Sound - Music increases in speed with alien speed.

AI - The aliens are positioned in a grid formation.
AI - When aliens reach side of screen they drop down, reverse direction and increase speed.
AI - A random alien fires at random intervals, the rate of fire is determined by speed.


Program


Current Assignments
AJ - Invader AI
Daygamer - User controls
Shadow - Destructable barriers
Eminent - Menus
Eli - Collision detection

Deadline For Release
12th September 2010

Libervurto
13
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 9th Aug 2010 00:15 Edited at: 9th Aug 2010 00:24
IMPORTANT: We will be using sprite for all graphics and collisions.

As project manager I will do the program structure, I will just make the program skeleton, I need you guys to make all the procedures.

AJAtom, you'll handle the invaders; I want you to start with their movement. Once you have that done make random invaders fire at random intervals.

Shadow, Can you work on the destructible barriers.

Daygamer, you are in charge of the player movement and firing.

Eminent, you are in charge of the menu and if possible the graphics.

xxelixx, are you still part of this project?


If you feel I've given you too much to do or you are stuck and need to ask questions just say.

That1Smart Guy
10
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 9th Aug 2010 01:22
ummmmmm hello? if u guys want me in on this then give me a task and ill get it done. also could u explain what u mean by defensive barriers?


Eminent
9
Years of Service
User Offline
Joined: 15th Jul 2010
Location:
Posted: 9th Aug 2010 03:25
Graphics eh. I get the best job .
Sinani201
12
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 9th Aug 2010 03:28
Defensive barriers are the block cluster above your character that blocks bullets from both sides. I'd pull up a pic but I'm on my iPod... type space invaders in google images and look at a gamelay pic and you'll see what I mean.

Look at your sig. Now look at mine. Now look at your sig. Now look at mine. Now look at your sig. Now BACK TO MINE.
AJAtom
10
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 9th Aug 2010 04:36 Edited at: 9th Aug 2010 04:44
I'm embarrassed to say but I have never played space invaders before.

edit:
nevermind ill get to that later

xxelixx
11
Years of Service
User Offline
Joined: 6th Dec 2008
Location: CodeLand
Posted: 9th Aug 2010 04:39
Yea i'm still in.

Sinani201
12
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 9th Aug 2010 04:45
A quick google search for space invaders gave me a flash version of the game.

http://www.spaceinvaders.de/

Look at your sig. Now look at mine. Now look at your sig. Now look at mine. Now look at your sig. Now BACK TO MINE.
AJAtom
10
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 9th Aug 2010 05:18
thanks sinani, except where I am the internet is a bit to slow to run the flash game.

Also perhaps we can make a sprite map to show which sprite numbers are the player, enemies, barrier, etc.
It could cause some collision if the sprite numbers i'm using for the enemies are already taken

Libervurto
13
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 9th Aug 2010 06:23 Edited at: 9th Aug 2010 06:28
@eli are you any good with sound? I have no idea how or where we could get the music and sound effects or make them.
If you have no luck with that then you could do the bullet movement for the player and invaders, moving the bullet and checking for collisions. I will give you more interesting jobs after that lol

@AJAtom
The invaders are positioned in a grid formation that moves across the screen, when the outermost invader touches the side of the screen they all move down a line and go the other way (and speed up). The tricky part is when you remove the outer lines of invaders from the formation, because you have to adjust when they change direction.

@Smartguy
Since you are more experienced could you help whoever needs help lol, thanks.

@All
Please post whatever work you have done by Wednesday night, so I have an idea of how you are getting on and how long things are taking.
Sorry if my tasks aren't very clear, don't hesitate to ask if you are unsure of what I want you to do.

BN2 Productions
15
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 9th Aug 2010 06:44
Quote: "are you any good with sound? I have no idea how or where we could get the music and sound effects or make them."


Perhaps all of the royalty free sounds/music that came with DBC?

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
AJAtom
10
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 9th Aug 2010 06:51 Edited at: 9th Aug 2010 07:05
ok so far I have this



pretty much the blocks are moving across the screen in a un-gridlike pattern, so I have 2 questions (also the game finally loaded)

1.How can I make the enemies move 20 spaces to the right, stop wait half a second and then move 20 more spaces (will worry about increasing speed later), the only way I could imagine is doing this



Which I guess would work, but there must be a better way.

2. How can I get the blocks to all move down at the same time.
I know why they aren't, for enemycrt can only equal one sprite at a time so that one sprite gets chosen to move down while the others wait their turn to be the one sprite selected.

also I took your advice and put as much comments as I thought needed and tried my hand at proper indenting.

BN2 Productions
15
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 9th Aug 2010 07:00 Edited at: 9th Aug 2010 07:14
@AJ

Not going to do it for you, but going to help you out with some logic here for the motion control.

In the left/right motion there are 4 possible cases:
1)Moving right and the alien in question is the right most alien in the row
2)Moving right and the alien in question is NOT the right most alien in the row
3)Moving Left and alien is left most
4)Moving left and alien is not left most

Up and down Cases:

1) Moving down and alien is already on the bottom row (about to trigger player loses condition)
2) Moving Down and alien is not on the bottom row.

If the alien IS at the farthest ends, you just have to check if moving will make it hit the edge. If its not, it just has to move based on what IS on the end.


PS. Food for thought for how to CONTROL the motion:


Don't just copy this, as it won't work for you. Its intended as a thought provoking example and will hopefully give you a spark of an idea.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
xxelixx
11
Years of Service
User Offline
Joined: 6th Dec 2008
Location: CodeLand
Posted: 9th Aug 2010 09:01
Quick question is this in classic or pro? I have both.

Sinani201
12
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 9th Aug 2010 09:07
They're working in DBC.

Look at your sig. Now look at mine. Now look at your sig. Now look at mine. Now look at your sig. Now BACK TO MINE.
xxelixx
11
Years of Service
User Offline
Joined: 6th Dec 2008
Location: CodeLand
Posted: 9th Aug 2010 09:14
Ok thank you.

Shadow000
9
Years of Service
User Offline
Joined: 31st Jul 2010
Location:
Posted: 9th Aug 2010 12:51 Edited at: 9th Aug 2010 15:08
Ok, I abandon the old thread, I'll be in this one now. I'll work on DBpro, and what's the differece between sprites and objects?
Also: How in the world I am ever gonna do the barriers? You want them so complicated... I'm gonna have to do a code for 40 sections that sustain three hits each, and be able to be placed each anywhere on the game...

Edit2: I used Google sketch-up for textures and I'm satisfied, how to save and use the picture? Also, a little help needed with coding. (Is it me or did I get the hardest job? )

Edit: Sorry, I had a couple of issues late this week, and some things I had to do, so I'm just starting



That1Smart Guy
10
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 9th Aug 2010 16:36
About the barriers, one idea i had would be:

1.create/load the imge for ONE barrier
2.Paste the 4 Barriers where they go on screen
3.Get an image of either the screen with JUST the 4 barriers, or just say the bottom 3rd of the screen (from the barriers down)
4.set up this image on a hidden bmp and each cycle get a new image of the barrier bmp


then just use a multidimmensional array to store the health/damage of each section in each barrier, and when a section gets destroyed then go to the barrier bmp and make a black box over the section that was destroyed, perhaps using another multidimmensional array to store the X and Y coordinates for each section in the barrier

if you need hard code i could whip some up, but its been a while since ive coded in DBC, im more here for logic and ideas than hard code


Shadow000
9
Years of Service
User Offline
Joined: 31st Jul 2010
Location:
Posted: 9th Aug 2010 17:17
I need help with the coding mainly, and I can't make bmp the image I created. It's .skp. I'll make a new one in paint (don't ask about quality, PLEASE) and fine, I'll make a black box over it. Most probably, the code will be like:

and so on for the rest. Trouble is, since I have nought programming experiance from before, and there's a very noticeable lack of tutorials on the subject, I don't think I'll manage it alone. Help plz



Eminent
9
Years of Service
User Offline
Joined: 15th Jul 2010
Location:
Posted: 9th Aug 2010 17:34
Its DBC? I thought you said we were using DBP.
That1Smart Guy
10
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 9th Aug 2010 18:15
@eminent - this is the DBC Board.....why would we use DBP?

@shadow you are using objects and this is a 2D game, use sprites instead. if u need me to post a lil code i can do so


Shadow000
9
Years of Service
User Offline
Joined: 31st Jul 2010
Location:
Posted: 9th Aug 2010 18:31 Edited at: 9th Aug 2010 18:32
I DO need you to post some code, I have absolutely NO idea on how sprites work. The only command I know about them is Draw sprites first and this doesn't help much.

Edit: I use DBpro, not DBClassic



That1Smart Guy
10
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 9th Aug 2010 18:36 Edited at: 9th Aug 2010 18:38
alrite no prob, i started on some code anyway just to see if it would work, gimme 10 min and it should be done

and while im typing if someone wants to explain to him what a sprite is that would help


Shadow000
9
Years of Service
User Offline
Joined: 31st Jul 2010
Location:
Posted: 9th Aug 2010 18:52
Me.



That1Smart Guy
10
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 9th Aug 2010 19:05
sorry this is taking longer than i thought.....gimme a few more min


Eminent
9
Years of Service
User Offline
Joined: 15th Jul 2010
Location:
Posted: 9th Aug 2010 19:25
He posted it on the DBPro newcomers forum. And most of us were using DBP so he said we would do it in DBP.
That1Smart Guy
10
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 9th Aug 2010 19:27
oh well im sorry i was unaware of this, all the projects i did with these guys were in DBC.

and i have DBP anyway so its no big deal either way to me


Daygamer
9
Years of Service
User Offline
Joined: 16th Mar 2010
Location: United States
Posted: 9th Aug 2010 19:29
looks like things are coming together. Here's what I've got:



Have I overlooked anything? Are any of my movements to fast or to slow.

Coding is just better with music
God Bless!
That1Smart Guy
10
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 9th Aug 2010 19:43
alrite im sick of fiddlin with this thing. it works for the most part, but there are a few glitches. this is one way to control the barriers, altho seeing how much work that was and how it still doesnt work im thinking there must be a better way

click on the top 2/3 of ech barrier 4 times to destroy that section....i have no idea why the bottom sections wont work, but im sick of messing with it. if u have any questions just call em out




Eminent
9
Years of Service
User Offline
Joined: 15th Jul 2010
Location:
Posted: 9th Aug 2010 19:53 Edited at: 9th Aug 2010 20:06
Man. I hate trying to make a sprite sheet in 3ds max. Im just gonna jack one of the internet kay?
By the way, for the sprite animation is using a jif possible?
Shadow000
9
Years of Service
User Offline
Joined: 31st Jul 2010
Location:
Posted: 9th Aug 2010 21:30 Edited at: 9th Aug 2010 21:35
As far as I know, it only accepts png and bmp. Tried some others, and they wouldn't work.

Also, I don't want to be mean or anything, since you did the work, but smartguy, your code doesn't seem to work. Text is in the middle and only the bottom part of barriers show up. I can't seem to do anything... Just tell me a couple of things about sprites and I'll see if I manage to improve on that

Edit: It does work, but I click on one part and another is damaged... Barriers are terribly hard. I think I should do some easy 1-hit-dead disappearing boxes.



xxelixx
11
Years of Service
User Offline
Joined: 6th Dec 2008
Location: CodeLand
Posted: 9th Aug 2010 21:37
Now I'm quite confused, should I be using DBPro or DBclassic?

Eminent
9
Years of Service
User Offline
Joined: 15th Jul 2010
Location:
Posted: 9th Aug 2010 22:17
How do I animate the Sprite then?
Libervurto
13
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 9th Aug 2010 22:23
We are using DBP because all the new members use DBP. This is what happens when you post important decisions in one thread and not the other

BN2 Productions
15
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 9th Aug 2010 22:39
Quote: "Now I'm quite confused, should I be using DBPro or DBclassic?"


Historically its been DBC, but if Obese made a judgement call, there you have it. For the most part, you guys should be writing code that is compilable in both languages, as you really shouldn't end dipping into the more complicated stuff.

Quote: "Man. I hate trying to make a sprite sheet in 3ds max. Im just gonna jack one of the internet kay?"


Sprite sheet? In 3ds max? Keep it simple. Use paint. Using 3ds Max to make 2d images is like bringing a shotgun to a knife fight.


Barrier Logic help for shadow:
First step: resource allocation
This doesn't mean to make the image (though you might as well), it means to decide on the size of the barrier, number of barriers, etc. and make an image that is that size filled with a random color (if you opt to not just make the image that is).

Second Step: Theory

Each barrier has a set amount of life that corresponds to how many times it can be hit (which was set by obese earlier in the thread). When it is at full health, the barrier looks new. When its hit once, it looks broken. Twice is more broken. Three times and its dead. You will want to control these values with variables (its health and its image-though a single variable would work if you play your cards right). Since there will be multiple barriers, instead of cluttering things with:
Barrier1health, Barrier2health, etc variables, just use a single array.

TDK has a pretty good tutorial on arrays here
Its about halfway down.

Third Step: Application
So now you have a general idea of where you are going, your next goal is to make 1 work. It doesn't have to be neat, it just has to work. Once it works, clean it up and optimize it to be more versatile (switch variable's to arrays, clean up commented out lines of code, etc). If it doesn't work anymore, go back and see what you changed/forgot to change. If it still works, test it out with 2 barriers. If that works, test 5. And so on and so on. Once you have a system that you can easily deploy into any program and make it work, pack it all up into subroutines and post it.

Hope this helps, I can do a bit of coding work, but its usually a good idea for you guys to do it on your own (you learn quite a bit from just trial and error).

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Daygamer
9
Years of Service
User Offline
Joined: 16th Mar 2010
Location: United States
Posted: 10th Aug 2010 00:17
Is this about what player movement and firing should look like. Is this to simple?



If this is okay, is there anything else I could do that would be helpful to the proj.

Coding is just better with music
God Bless!
BN2 Productions
15
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 10th Aug 2010 00:27
Not my call but it looks pretty good, daygamer. I would suggest however using REM for comments and ` for commenting out lines of code so that they don't get mixed up. For example:


See how they are almost identical at the beginning? If you put a REM there it is easier to spot that its a comment, rather than just a line of code you don't want the compiler to compile.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Eminent
9
Years of Service
User Offline
Joined: 15th Jul 2010
Location:
Posted: 10th Aug 2010 00:43
Im done menu. Its ugly but Ill fix it later.

Hmm, How shall I make the game pause?
BN2 Productions
15
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 10th Aug 2010 00:48
Couple things here


Why? Could you not just replace all of that with a single wait key? THere seems no purpose for a GOSUB here, nor a subroutine, not to mention that Clicky has no return command. When you run this, once you exit the REPEAT-UNTIL loop it will simply return to the WAIT KEY (the line after the last gosub was called) and then go into Clicky again.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Eminent
9
Years of Service
User Offline
Joined: 15th Jul 2010
Location:
Posted: 10th Aug 2010 01:02
Oh. I just put the wait key so when I was experimenting the box xy values it wouldnt just make the bix, wait for a millisecond and end.
AJAtom
10
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 10th Aug 2010 01:13 Edited at: 10th Aug 2010 03:19
daygamer, wouldn't it be easier just to make the bullet a sprite so we could detect collision with an alien easier?
unless you have an idea already formed, because im plum

also @anyone, does your step-through mode still work because mine never compiles

Daygamer
9
Years of Service
User Offline
Joined: 16th Mar 2010
Location: United States
Posted: 10th Aug 2010 01:20 Edited at: 10th Aug 2010 01:56
that's a good point about "rem", BN2. thanks. Eminent, your menu works great. Yeah, it would be cool if you spiced it up a little though.

Yeah, that might be a good idea, AJAtom.

Coding is just better with music
God Bless!
Daygamer
9
Years of Service
User Offline
Joined: 16th Mar 2010
Location: United States
Posted: 10th Aug 2010 01:53 Edited at: 10th Aug 2010 01:55
sorry, accidental double post

Coding is just better with music
God Bless!
BN2 Productions
15
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 10th Aug 2010 03:27
@Eminent

ITs a good thing you caught the wait key being a temporary line, but my point was that the GOSUB seems to be irrelevant. If its not (ie it is there so that you can go to clicky without going to the other stuff) then you should separate it as its own subroutine and put a return at the end of it, otherwise you will run into trouble when you try to "install" it into the main code.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Eminent
9
Years of Service
User Offline
Joined: 15th Jul 2010
Location:
Posted: 10th Aug 2010 03:39 Edited at: 10th Aug 2010 03:40
I have a question BN2, how would I make the game pause? And animate a sprite?
BN2 Productions
15
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 10th Aug 2010 03:52
To pause:

The best way to explain is with a picture that I will attempt here

Here is the program without a way to pause:


Here is what it would look like when you pause it




Make sense? In words, normally in the loop you do all the game stuff. However, if the player clicks the pause button, instead of doing all that stuff, you go to a subroutine and do the pause menu stuff instead. This is especially easy if the stuff that is normally executed is a subroutine itself. That way your main loop just contains a simple check of



As you get more menus and blocks of code to be looped, you will want to look into using the SELECT command instead along with a single variable that controls where the program goes (I can elaborate if you would like).


Animating a sprite is easy, just change the image for the sprite every X number of iterations. Something like this:


See how that works?

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Eminent
9
Years of Service
User Offline
Joined: 15th Jul 2010
Location:
Posted: 10th Aug 2010 04:16
I dont get the animate one but I do get the pause one kinda.
BN2 Productions
15
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 10th Aug 2010 04:31
Alright for the animate one:



I will explain this line by line:

DO-SO that it never ends NOT IMPORTANT FOR ANYTHING HERE OTHER THAN COMPLETENESS

INC Counter - I probably should have initialized this earlier. Counter is just a variable that I gave an ambiguous name to. This code will increase its value by one every loop though the DO loop

If COunter=25 - This will control how fast or slow the animation is. Lowering 25 means it will take fewer times through the DO loop to make the image change

Counter=0 - This keeps from having to do math in order to figure out if it is an even multiple of 25. By resetting to 0, you just have to care when its 25, not 50, 75,100 etc etc etc.

IF imgnumber<>2 - I will include the explanation for the whole IF block there. It reads in english: If the variable imgnumber is not equal to 2, then set the variable number equal to 2. Otherwise, that is, if imgnumber IS equal to 2, then set imgnumber equal to 1. What this means is that every time this block of code is run, it will switch the variable between having a value of 1 and 2.

Sprite 1,X,Y,imgnumber - The sprite command takes 4 arguments. The first is the sprite number. Don't mess with this when animating because you will just end up with tons of sprites, rather than just 1 sprite with several possible animation frames. X and Y are the coordinates to place the sprite. I put X and Y because they aren't important in this example. Placing a variable (in this case the imgnumber variable that will always be either 1 or 2) as the fourth argument tells the program to use whatever image has the same value as the variable. If imgnumber equals 1, then use image number 1 for the sprite. If imgnumber equals 2, then use image number 2 for the sprite.

For larger sets of animation (which you DON'T NEED FOR THIS PROJECT BECAUSE THERE IS ONLY A MAX OF 2 FRAMES PER SPRITE) it would get more tricky. Basically, instead of just switching between 1 and 2, every 25 iterations through the loop, you could increase the imgnumber variable (or whatever you choose to call it) by 1. Once you hit the max number of frames, you would use an IF-THEN to reset the value of imgnumber to 1 like so:


Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Eminent
9
Years of Service
User Offline
Joined: 15th Jul 2010
Location:
Posted: 10th Aug 2010 04:51
I made this program to test out how to pause but it doesnt work.
BN2 Productions
15
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 10th Aug 2010 05:25
Change the keystate check in the paused subroutine to another key for one thing. Another thing here is you have 2 "main" loops going on. The FOR-NEXT loop and the REPEAT-UNTIL loop.

Try this:


See how that works?

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose

Login to post a reply

Server time is: 2019-12-16 10:15:12
Your offset time is: 2019-12-16 10:15:12