Missile Command

The Partridge Family were neither partridges nor a family. Discuss.
User avatar
Asimov
Posts: 814
Joined: May 19th, 2012, 11:38 pm

Re: Missile Command

Post by Asimov » June 3rd, 2012, 11:00 pm

Hi Lux,

Nice one for that. Downloaded tutorial 19 materials and will look soon. Just designed my backdrop to the game in photoshop and using your Lux scanner to scan it. Takes ages to scan 800 * 600 though LOL. I am up to line 11 now heh heh.

Anyway I got my explosions to look good. Wait untiil you see my new backdrop for the game.
Now I could use the new bmp loader from tutorial 20, but this way I can have the picture embedded in the exe without it being separate.

I think later we will be able to load in a surface and save it as a resource file so it can be embedded in the exe.

Asimov
Attachments
Whitelight.jpg
Whitelight.jpg (7.13 KiB) Viewed 3743 times
----> Asimov
"You know no matter how much I think I have learnt. I always end up hitting brick walls"
http://www.asimoventerprises.co.uk

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: Missile Command

Post by LuX » June 3rd, 2012, 11:25 pm

>.> That's a big image to be scanned. Personally, if I were to scan such a huge image, I would have just split it up and scanned using 1.5, and then let the framework put them together again.

Anyways, cool that you like the program. I actually worked few days back on a way to directly load scanned images from the text file, without having to paste the code to the framework and also made a function to rotate these images, tho they get a bit messed when you turn them towards 45 deg, get some nasty holes in between. Also looking to make rotating text and cool shit like that.
ʕ •ᴥ•ʔ

User avatar
Asimov
Posts: 814
Joined: May 19th, 2012, 11:38 pm

Re: Missile Command

Post by Asimov » June 4th, 2012, 8:42 pm

Hi Lux,

Strangely enough the file is still scanning from yesterday. I am up to line 72, it is taking forever. The game will look much better when I got my backdrop in. I wish there was a faster solution. Perhaps there is a way to use the loadbmp function and make that convert an image to putpixel commands. C++ has to be faster than basic.
I would use the loadbmp if there was a way of keeping my images inside the exe. Wish I could do that with sounds as well. I like the old days when you just give someone an exe and they don't need a folder full of stuff.

Clipping is now sorted. Thanks for the help there.

Just implemented a few basic sounds. A lot of wavs wouldn't work. In the end the ones that wouldn't work I run through adobe audition and they were ok after that.

A couple of things with sound. First of all if the program can't find the sound it just crashes.
So is there a c++ version of If Exists file ? Basically if it can't find the sounds I want it to carry on running without sound, without crashing?

Got a long way to go yet. Haven't even started on the alien missiles yet. Then I have to build the laser and then build the cities which will get destroyed in the invasion.

Asimov
----> Asimov
"You know no matter how much I think I have learnt. I always end up hitting brick walls"
http://www.asimoventerprises.co.uk

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: Missile Command

Post by LuX » June 4th, 2012, 9:19 pm

Basically if it can't find the sounds I want it to carry on running without sound, without crashing?
You could use the "try" and "catch" commands.
ʕ •ᴥ•ʔ

User avatar
Asimov
Posts: 814
Joined: May 19th, 2012, 11:38 pm

Re: Missile Command

Post by Asimov » June 4th, 2012, 9:28 pm

Hi Lux,

The catch would have to be put in the sound class for it to work, because that is where it crashes. I don't know enough about the sound class to mess too much LOL. Wheras if I use an IF EXISTS check I could call it before calling the sound class.

Asimov
----> Asimov
"You know no matter how much I think I have learnt. I always end up hitting brick walls"
http://www.asimoventerprises.co.uk

User avatar
Asimov
Posts: 814
Joined: May 19th, 2012, 11:38 pm

Re: Missile Command

Post by Asimov » June 4th, 2012, 9:49 pm

Hi all,

I am really stuck ignoring the velocity problem.
The code I put in should stop the mouse key repeating, but it isn't working. The idea is that if I hold down mouse without lifting it then it should only fire once. I cannot understand why the code is failing. My log out put is showing false as if they key is never being set to true. ie

key pressed last frame is 0
key pressed last frame is 0
key pressed last frame is 0
key pressed last frame is 0
key pressed last frame is 0
key pressed last frame is 0
key pressed last frame is 0
key pressed last frame is 0
key pressed last frame is 0

However when the key is pressed it should be set to true until the the next frame. Here is the code in question.

Code: Select all

if (mouse.IsInWindow() && mouse.LeftIsPressed() && !Missile[missilecount].Fired && !keypressedlastframe)
	{
		//sound
		fire.Play();
		Missile[missilecount].FireMissile(true,mouse.GetMouseX(),mouse.GetMouseY() );
		missilecount++;
			
		if (missilecount>=NOM)
			{
				missilecount=0;
			}
		keypressedlastframe=true;
	}		
	else
		{
			keypressedlastframe=false;
		}
I am totally stuck on this.

Asimov
----> Asimov
"You know no matter how much I think I have learnt. I always end up hitting brick walls"
http://www.asimoventerprises.co.uk

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: Missile Command

Post by LuX » June 4th, 2012, 10:20 pm

Not sure if I understood you correctly: you want to make it shoot once each time you press your mouse down and play the shooting sound?

First make a boolean in the .h file, something like bool msdw and make it false.
Then for the mouse click run a check if msdw == false and make it true until mouse is lifted.

As for music playing. I suggest you make an array of rockets and with the same value an array of music. Then once you shoot you have something like:

Code: Select all

...
for (int n = 0; n < MaxRockets; n++)
{
    if (RocketNotShotYet[n] == true)
    {
        RocketNotShotYet[n] == false;
        fire[n].play(0);
    }
}
...
and once the rocket has exploded just make NotShotYet[n] = true.
Basically you make a separate sound for each rocket as the .play wont play the exact same sound multiple times, it just goes to the beginning of the sound.

And so on...
ʕ •ᴥ•ʔ

User avatar
Asimov
Posts: 814
Joined: May 19th, 2012, 11:38 pm

Re: Missile Command

Post by Asimov » June 4th, 2012, 10:34 pm

Hi Lux,

Strangely enough with the bool, I have done that. If you look at the code I posted you notice the variable !keypressedlastframe. Which is on the line

if (mouse.IsInWindow() && mouse.LeftIsPressed() && !Missile[missilecount].Fired && !keypressedlastframe)

I iniatially set it to false.

Then when the mouse is pressed it is supposed to set it to true.

You can see the line keypressedlastframe=true; before it exits the mouse press section.

However after looking at the logs keypressedlastframe never seems to be set to true at all, even though I have set it in the code.

In theory if I don't lift the mouse it should not fire again, and yet it is.

As for sounds I have no problem with the sound part of the program, although I am investigating adding sounds as a resource so that I can compile them into the exe as well.

I am determined to crack this. gonna try a break point on where it is set to true now to see if it ever does get set.

Asimov
----> Asimov
"You know no matter how much I think I have learnt. I always end up hitting brick walls"
http://www.asimoventerprises.co.uk

User avatar
Asimov
Posts: 814
Joined: May 19th, 2012, 11:38 pm

Re: Missile Command

Post by Asimov » June 5th, 2012, 10:48 am

Hi all,

Seem to have a new problem now. Anyway Lux I was waiting too long for your program to convert my picture into putpixel lines so I tried Chilli's fukbmp, and do you know it isn't as pretty as yours, but it converted my picture in about 1 second flat. I thought there was something wrong, but no all 480000 lines were there. Surely C++ isn't that fast?

Anyway to cut a long story short I put all those lines inside my program and hit the compile button. Anyway that was last night and it is still compiling today. I am not sure if it is ever going to finish.
I wish it showed you a progress bar or something.

I might have to succumb to the loadbmp tutorial, but the reason I wanted it in pixels is this. I wanted to do a fancy fade onto the screen which needed acess to the pixels. Also Chilli said that the system he showed in the tutorial isn't robust, and he would have used gdi. Is gdi easier than the loadbmp function? I have been looking for solutions in google LOL without success.

Once I use loadbmp can I still access individual pixels or am I just stuck with the surface created?

Asimov
----> Asimov
"You know no matter how much I think I have learnt. I always end up hitting brick walls"
http://www.asimoventerprises.co.uk

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Missile Command

Post by chili » June 5th, 2012, 11:07 am

I kinda figured that the compling would take forever. Never guessed it would be THAT long though. :lol:

The surface is just an array of pixels. You can access them to your heart's content Asimov.
GDI+ is a lot easier and better. It's slower than if you roll your own like we do in my tutorial, but since loading is just done once at the beginning of the game, it really doesn't matter that much from a performance perspective.

Anyways, do the tutorial Asimov. :evil:
Chili

Post Reply