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
Daygamer
14
Years of Service
User Offline
Joined: 16th Mar 2010
Location: United States
Posted: 23rd Aug 2010 21:35
yes, welcome back, Eminent. You done anything to that menu?

yrotate when you can spin?
God Bless!
Eminent
13
Years of Service
User Offline
Joined: 15th Jul 2010
Location:
Posted: 23rd Aug 2010 21:49
Not really. I might photoshop something though. I really cant understand animation.


BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 23rd Aug 2010 22:44 Edited at: 24th Aug 2010 01:59
@Eminent
If you can elaborate on what you don't understand with animation, we can help you a little better. As it is, I feel like we just keep saying the same thing over and over.

Here's a program that might help out a bit.


It may be helpful if I point this out. An animation is NOT a picture that moves. It is just like a film reel. No picture actually MOVES in a film. Rather, there are a BUNCH of pictures that are switched through VERY FAST in order to make it LOOK like something is moving.

Hopefully this will help a little bit.

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
13
Years of Service
User Offline
Joined: 15th Jul 2010
Location:
Posted: 23rd Aug 2010 23:09
OHHHH now I get it. I didnt get what you were doing with that last part of the sprite command. Ive made a couple images for the menu.
I try to load them but it doesnt work. Here is the code:
I included the play media.



Attachments

Login to view attachments
Daygamer
14
Years of Service
User Offline
Joined: 16th Mar 2010
Location: United States
Posted: 24th Aug 2010 07:29
anything I can help with right now? assuming my code is fine.

yrotate when you can spin?
God Bless!
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 24th Aug 2010 09:59
Well, while you're sitting on your hands I could nitpick for you

Will get around to testing it in the morning, though I cant imagine any problems. Indent your subroutines so its easier to spot the beginnings and the endings.

Other order of business, throw in a do loop that calls the appropriate subroutines. Basically make it a complete program, just with only subroutine calls in the Do Loop.

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
14
Years of Service
User Offline
Joined: 16th Mar 2010
Location: United States
Posted: 24th Aug 2010 17:49
@BN2, thanks for the nitpick.

K, I've set it up so you can test it with no media. However, The bullet is not appearing in my editor. I've spent the last 20 minutes trying to figure it out. I tried the same code in a blank project and it works fine, so whatever.

Also I think these subroutines could be deleted: load_sprites, draw_sprites.





yrotate when you can spin?
God Bless!
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 24th Aug 2010 23:53
@ Daygamer
Instead of drawing the ship and bullet every loop you should draw them at the start of the program and grab them as images, then we can use them with sprites so when we have the proper graphics we can just replace the image without editing the code. This is called using placeholders.

As for the bullet not displaying, I can't see an obvious reason. You're going to have to do a bit of debugging. There are two main methods of debugging I use, I don't think there is a proper name for them so I will call them quarantine and exposure.
Quarantine is when you rem out sections of your code that you think might contain the bug, you must do this in a way that the program will still execute i.e.

Here we've only left one line open because we have no idea where the bug is. We test the program and it runs perfectly, so we un-rem another line and test again until we find the line that is causing the error. The error is in the third line of printing, we have forgotten to put a closing quotation mark.
Subroutines are very useful when debugging, you can easily turn whole subs on and off to isolate the one that contains the bug.

Exposure is when you display everything that is hidden so you can see what's going on inside the program. You've probably seen videos of test programs with lots of numbers on the side of the screen, these numbers are all the variables used in the program. Most variables are never displayed to the user so we have to display them to check they are behaving as intended.

Since your program works, you should try exposure. A nice touch is to make a separate debugging subroutine and make it so it will only display the variable info when a key is pressed. That way you can test your code as it will appear to the user and check up on variables if you need to.
--

I noticed you don't have a sync on command, you must have this at the top of your program if you wish to using the manual sync command. Without sync on the program will try to refresh the screen after every output operation which will make your program lag. Switching to manual sync means the output is written to the output buffer and will only be displayed on screen when a sync command is found, this gives a much smoother display.

One little thing you might not know: you can write if bullet_fired=1 simply as if bullet_fired, this is because the action IF takes is based on the result of its condition, 0 = false and 1 (or >0) = true.
So if bullet_fired = 1 you could say that bullet_fired is true. I don't think it makes much difference to the program but it's nice to know and it makes the program flow more linguistically, especially if you have good variable names. You don't have to be a programmer to know what this means: If bullet_fired then show sprite 2

Daygamer
14
Years of Service
User Offline
Joined: 16th Mar 2010
Location: United States
Posted: 25th Aug 2010 02:05 Edited at: 25th Aug 2010 02:10
@Obese, Thanks for the tips on everything.

I did use the exposure thing to help me start tracking down my problem. It turned out my project file was looking to the wrong dba file or something, cause I deleted them all out of the project, and it works happily

Here's my current code:



You think I could delete the load_sprites and draw_sprites subroutines since I'm not using them at the moment. I would have them backed up in another file.

Edit:
Quote: "Instead of drawing the ship and bullet every loop you should draw them at the start of the program and grab them as images, then we can use them with sprites so when we have the proper graphics we can just replace the image without editing the code. This is called using placeholders."


Could I have some code. I'm having trouble picturing how to do this.

yrotate when you can spin?
God Bless!
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 25th Aug 2010 08:49
Use GET IMAGE to grab a portion of the screen/bitmap and store it as an image.

Daygamer
14
Years of Service
User Offline
Joined: 16th Mar 2010
Location: United States
Posted: 26th Aug 2010 06:10
okay, got it.

yrotate when you can spin?
God Bless!
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 27th Aug 2010 11:09
Sooo, been a couple days of silence how are things coming along?

@Eminent
Any luck getting the animations and stuff to work?

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
15
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 28th Aug 2010 00:56
I havent been able to program all week, so I dont have a progress report

Daygamer
14
Years of Service
User Offline
Joined: 16th Mar 2010
Location: United States
Posted: 28th Aug 2010 07:54
sorry about that AJ. Hope next week goes better for ya.

To keep the posts going, here's my code with Obese suggestion on the GET IMAGE command. I never used it like this so hopefully it's alright.

Also I delete some code I wasn't using, but I got it back up if I ever need it. Just wanted to un-clutter things.



yrotate when you can spin?
God Bless!
Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 28th Aug 2010 23:16 Edited at: 31st Aug 2010 05:16
Hi everyone it's been a while. There's alot of progress comming along here, but I've notice the graphics may be lacking a bit, maybe I can help out in that area?

Attachments

Login to view attachments
Eminent
13
Years of Service
User Offline
Joined: 15th Jul 2010
Location:
Posted: 29th Aug 2010 04:25
Nah. Cant get Paste Image to work. And cant work on the menu because of the that reason too.


Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 29th Aug 2010 04:35 Edited at: 29th Aug 2010 05:21
@Eminent
Can you post your code using PASTE IMAGE?

@Ashingda
Hi mate, that would be great. I'm not sure what dimensions to use yet, but if you can work out something I'm sure we could work with what you give us.

@Daygamer
Yes that looks fine to me.
You did however make a common mistake with the co-ordinates you gave to GET IMAGE; you are giving the command a range of cells, and like any range the upper limit is NOT within the range. To capture a single cell at 0,0 you'd write GET IMAGE img,0,0,1,1.

A couple of extra things that might make your life easier:

It's simpler if we draw the images in the top left corner, also because we aren't using the player and bullet positions to draw them, the program is more flexible as drawing the images no longer relies on the variables being initialised; using minus values means that the image will be drawn of screen if the variables aren't given the right values. The more independent our blocks of code are, the more flexible the program is.

I did introduce two variables of my own: these are img_shp and img_blt, I added them because there may be a reason that we later want to change the image numbers we use, if we stored the numbers in variables beforehand we'd only have to change their initial values, otherwise we'd have to edit the image numbers in the whole program. A useful side-effect of using variables is we can give them descriptive names that tell us what the image is used for.

Eminent
13
Years of Service
User Offline
Joined: 15th Jul 2010
Location:
Posted: 29th Aug 2010 04:46
In the last page.


Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 29th Aug 2010 05:27 Edited at: 29th Aug 2010 05:28
@Eminent
I just copied your code to here.

I can't test it but it could be a couple of things. Have you used PASTE IMAGE before successfully?
Have you tried removing the loop and running?
Have you switched to an off-screen bitmap? The image would be pasted there instead of on screen.
Is the image being loaded properly?

Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 29th Aug 2010 06:22
I know I already posted this in the other thread, but does anyone need help with anything? I just got my new computer and I'm ready to do something.

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.
Daygamer
14
Years of Service
User Offline
Joined: 16th Mar 2010
Location: United States
Posted: 29th Aug 2010 08:03
@Obese, as usual, great suggestions. I've updated my code.

yrotate when you can spin?
God Bless!
Eminent
13
Years of Service
User Offline
Joined: 15th Jul 2010
Location:
Posted: 29th Aug 2010 23:29
I havent got around to animations. Maybe you can do it.


Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 31st Aug 2010 05:22 Edited at: 31st Aug 2010 05:25
Here is a quick three frame spacecraft. One normal frame and two death frames. It's stored as seperate Images "1.png", "2.png" and "3.png" for easy loading. The background is already transparent.


Example: This is just to show the 3 frames side by side.


Attachments

Login to view attachments
Daygamer
14
Years of Service
User Offline
Joined: 16th Mar 2010
Location: United States
Posted: 31st Aug 2010 06:57
that does look pretty good. What does Obese think?

yrotate when you can spin?
God Bless!
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 31st Aug 2010 09:04 Edited at: 31st Aug 2010 09:32
Hey I built a system to handle the animations. The EXE is attached.

I'm fine with releasing the code so you guys can learn from it, Obese's call though.

Once it starts just click around the screen. I intentionally did NOT use a flag variable, that way you can click and drag.

@ashingda
Ship looks good. Might need a bit of scaling down though, but good nonetheless.

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

Attachments

Login to view attachments
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 31st Aug 2010 15:40 Edited at: 31st Aug 2010 15:51
@BN2
Yes, that's fine. Animation is halting progress. Not your fault Eminent, there's obviously something we haven't explained properly, hopefully you can find out yourself when you see the whole code.

@Ashingda
Good work, I don't think it needs scaling
Are you going to do invaders too? I'd actually prefer if they don't look like the original space invaders (considering the style you've used for the ship) If you can come up with your own aliens that would be awesome
Could I request a rocket for the ship's "bullet" with two frames (like it's rotating)?

@Shadow
Haven't seen you around for a while.
I've decided the barriers should be single objects and take 3 hits before being destroyed on the 4th hit. This will be simpler.

I like the tactic of using the barriers as cover and shooting through them, I'd like to keep this in the game. We can do this by simply allowing the player's missiles to pass through the barriers without collision.

@All
We need to pick up the pace a bit, only 11 more days to go if we're going to be on schedule!

Daygamer
14
Years of Service
User Offline
Joined: 16th Mar 2010
Location: United States
Posted: 31st Aug 2010 17:16
@Obese, do you want me to work on the barriers since we haven't seen Shadow in a while?

yrotate when you can spin?
God Bless!
Eminent
13
Years of Service
User Offline
Joined: 15th Jul 2010
Location:
Posted: 31st Aug 2010 18:28
No, I know how to do it but I just cant get paste image to work.


Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 31st Aug 2010 19:40
I'm still willing to help with anything if you guys need it...

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.
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 31st Aug 2010 21:04 Edited at: 31st Aug 2010 21:05
Roger that, here is the code for the animation system.

It could probably use some optimization, but it should work fine for our uses. Also, its made to use sprites, but it should be a simple tweak to make it work with Paste Image or something similar.

@Sinani
Until there is a job opening, did you want to look into optimizing the animation code? I am sure some things can be condensed, FOR-NEXT loop iterations can be cut down, etc.



Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 31st Aug 2010 21:07 Edited at: 31st Aug 2010 21:16
Hm, I'll see what I can do.

So, just wondering, why are there 65535 loops in the program? I'm somewhat confused about what each one is for, you didn't mention it in the comments.

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.
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 31st Aug 2010 21:17
65535 is the max number of sprites allowed. It just runs a scan through all of them (I imagine it will be shortened down once we see exactly where the upper limit of our resource usage is).

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 1st Sep 2010 01:15 Edited at: 1st Sep 2010 01:27
@Sinani
I read your sig, but there was no RETURN statement in mine so I couldn't finish reading yours

Since you're a bit more experienced we will need your help checking code and putting the full program together.

@Daygamer
Yes thanks, you can start work on the barriers.

@AJ and Eminent
Are you working or waiting for new jobs?

Daygamer
14
Years of Service
User Offline
Joined: 16th Mar 2010
Location: United States
Posted: 1st Sep 2010 17:04
@Obese, cool, I'll get working as soon as possible.

yrotate when you can spin?
God Bless!
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 2nd Sep 2010 19:03 Edited at: 2nd Sep 2010 19:05
Hi all,
I am going away tonight for a few days and wont be back until Monday.

I'm afraid I haven't been very organised and I've lost what people are doing and what code is ready to be used, but hey this is a learning process for me too .

If you have something to work on keep at it, if you don't I'm sure people who have been following the thread (like BN2 and Sinani) will be able to give some guidance. Don't worry about getting too much done while I'm away, consider this a rest period, when I get back I want us all to go at it full pelt and try and get this thing finished on time or at least only a few days over schedule.

Cheers.

Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 2nd Sep 2010 20:06
Well, most of the animation code looked pretty good. One change I made was a little line of code I put in the top of the for loop in UpdateAnimations() :



It will exit the for loop after it has seen the last sprite. That way, if there are only 10 sprites, it's not going through 65525 more useless loops of sprites that don't exist.

The rest of the code looks fine; I'm not really sure what else there is to change. If you need anything, let me know.



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.
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 2nd Sep 2010 20:14
Seems like an interesting structure for that extra if-then.

Why not just this?


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
13
Years of Service
User Offline
Joined: 15th Jul 2010
Location:
Posted: 2nd Sep 2010 20:21
Im working to make the menu a bit flashier.


Sinani201
17
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 2nd Sep 2010 20:29 Edited at: 2nd Sep 2010 20:29
@BN2
Right, I forgot that I could do that; that makes it a lot better. As you can probably see, I haven't been in DB for a while. Thanks.

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
15
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 5th Sep 2010 19:48
Yes pretty much, Ive updated my aliens with Arrays.

I will post it later once I get back to my computer

Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 8th Sep 2010 14:38
Hi everyone,
I haven't posted because I've been ill. It's clearing up today so I might be able to look at this later.
I think we should extend the deadline to 19th September, I don't think we can get this finished in four days.

How are you all? Done anything good over the weekend? Ready to get back to finishing this?

Daygamer
14
Years of Service
User Offline
Joined: 16th Mar 2010
Location: United States
Posted: 8th Sep 2010 23:21
@OBese, Great to have you back. Yes, we need to extend our deadline. I'm moving this weekend anyway.

I have worked on barriers. It got pretty messy. At least it works fine.

I approached destroying the barriers by dimming their color and recreating them. There must be a better way; they flash when as they are updated.





yrotate when you can spin?
God Bless!
AJAtom
15
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 9th Sep 2010 00:27 Edited at: 9th Sep 2010 00:41
well I pretty much doubled the comments on it from the last time (spelling is not perfect), but anyway here it is, what I do in my part are the subroutines

Enemy_creation
Enemyprops
Alienshot

and all the variables of course



Daygamer
14
Years of Service
User Offline
Joined: 16th Mar 2010
Location: United States
Posted: 9th Sep 2010 06:02
@AJAtom, impressive code I had a couple of the aliens on the left side of the grid glitch up a little when they hit the left side of the screen. One disappeared and one frooze. The alien bullets are awesome though. Good job, man

yrotate when you can spin?
God Bless!
AJAtom
15
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 12th Sep 2010 02:40 Edited at: 12th Sep 2010 02:41
@daygamer

I started reworking your code, but at the end of it all I had something that looks completely different.
I never found out what the problem was....but I solved it.



AJAtom
15
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 13th Sep 2010 03:14
This thing cant be dying. We haven't even got to the good stuff yet.

What has Eminent been up to?

Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 14th Sep 2010 01:59 Edited at: 14th Sep 2010 02:09
Here's a couple of suggestions in hopes that this project won't die.

1. Decide on a structure for the program. I saw a skeleton earlier on, but I don't see any real adherence to it.

2. Organize the code a little more consistently
It seems there are tons of little snippets here and there, but no standard or complete structure of the code. There are multiple screen resolutions, main loops, variables used here and there... This needs to be gelled a little more - just for ease of adding to it or removing and editing things.

3. Don't be afraid to take on a task that isn't getting done. If someone has disappeared and you really want to finish this thing, pick up their slack and work out that portion of the program.

4. The only way this'll get done is if it gets worked on.

For number 2, I went through most of the messages in this thread and gleaned what I thought were the most complete blocks of code. I organized them in a coding structure I use often and included it as a code snippet.

The top part is the header. It has the project title, the date etc. It also has a comment section. This is useful to maintain a change log of additions or changes to the program. If you date each entry (the most recent at the top) you can get an idea of progress.

The next section is the main loop. This is where the main subroutines and functions should be called from. There really shouldn't be any variable definitions here if you can help it.

The next section is for subroutines. I organized this section by coder so any subroutines a specific individual adds should go in their section. Each name section is separated by a single set of equal sign dividers:
`===========================

The first group is for common variables or code. These are variables or global/universal setup that the entire program will use. Place all variables in this section so that users don't repeat variable names and inadvertently change a value for someone else.

The next section is for functions. This is organized exactly like the subroutine section - by name and a common area (which won't store variables but maybe something like mouse_within() )

The final section is for data statements.

Feel free to use this structure. It may help. As it stands, it needs adjusting so the code runs properly. Each programmer should add any of their code in the form of functions or subroutines. They should call their subroutines from the main section. Check through your section and make sure your code is updated. Add calls from main to make sure it works. Any code you submit should be as an addition or change to this main document. That way, everyone has access the latest updates - and the whole code can be tested. (that means saving this document to your machine, making an update, and posting it in a new message or editing one of your existing messages if it is the last one in the thread)



Enjoy your day.
Daygamer
14
Years of Service
User Offline
Joined: 16th Mar 2010
Location: United States
Posted: 14th Sep 2010 07:34
Sorry I haven't posted in a couple of days. I've been moving. No internet

@Latch, thanks for the help on this project. I can't try your code at the moment. It looks like a lot of hard work though.

yrotate when you can spin?
God Bless!
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 14th Sep 2010 16:25
Thanks Latch . In future we will have to come up with a better system for managing code.

Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 15th Sep 2010 05:19
This part is a bit difficult for me because I can't test the code at home, to be honest I've been quiet because I've gotten a bit lost with this project, Latch's code helps. I will try to test it tomorrow and see where we go from there. I think we have most of the work done, we now need to make a game out of all this code!
I think we can still hit the 19th deadline. NOOBS TEAM ASSEMBLE! (Anchorman )

Login to post a reply

Server time is: 2024-04-20 09:32:41
Your offset time is: 2024-04-20 09:32:41