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.

2D All the way! / space invader clone

Author
Message
David_M_
19
Years of Service
User Offline
Joined: 27th May 2005
Location:
Posted: 2nd Aug 2005 08:51
I tried to make the "firing trigger" work off of a single click instead of just a press of the mouse button. I made a subroutine for a single click:

and designage the if statement with singleclick=1 instead of "if mouse click() = 1".
It kinda works, except that the program seems to remember how may times I have clicked even after I stop clicking. In other words, if I click numerous times it will still fire a few times after I stop clicking. I even tried putting click=0 and singleclick=0 in numerous places in the program to reset things, but it still does it.
I hope this makes sence.

thanks,
David
David_M_
19
Years of Service
User Offline
Joined: 27th May 2005
Location:
Posted: 2nd Aug 2005 08:56
BTW, why is the folder for this thread red??
D Ogre
21
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 4th Aug 2005 02:31
Where are you placing the subroutine call in the code? Is It at the beginning?

Just looking at your code snippet, I can see a problem. It will still fire more than once because the subroutine hasn't been reset properly.

Upon the initial pass of the loop your CLICK and SINGLECLICK variables will be zero. After you hit the mouse button, CLICK and SINGLECLICK are set to one. I assume that you are checking in the actual fire routine for SINGLECLICK to be 1, but you will need to check for it to be zero in the mouseclick part.

Maybe something like this:



You will have to set CLICK back to zero once all of the lasers hit an invader or make it off the screen. You could use a variable to tally up the results and then do a check to see if it equals the powerup.

Generic example:



Does this make sense?
David_M_
19
Years of Service
User Offline
Joined: 27th May 2005
Location:
Posted: 5th Aug 2005 07:24
Hello D Ogre,
I have played with the trigger mechanism for quite a few hours now (atleast 6 or so) and have decided to not use the single click stuff, because I do want it so that you can hold down the mouse button. I have tried the other methods, but can not get to work properly. I can get it to partially work, but not right. Your suggested code that has the offset in the laser y position:

does spread out the lasers, but it also makes them start at varing distances from the front of the ship, depending if the last laser went off screen or hit an invader. If I take out the "-shot*20" it acts really quirky. Sometimes multiple laser shot and sometimes they dont, and sometimes they shot in groups of two or three. I tried to implement the last suggestion, but could not get it either. Here is my complete code, maybe you can give me more ideas with the whole thing instead of just snippits.


Thanks again,
David
D Ogre
21
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 8th Aug 2005 23:07
I was afraid of this, I know the trigger was a little quirky. I will have to do some changes for you to clear it up. Basically, what we need to do is make the trigger check to see where the previous laser is before it fires another forcing it to keep each at a specific interval.
I will try working it out tonight...
D Ogre
21
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 10th Aug 2005 07:11 Edited at: 10th Aug 2005 07:16
Here is my mods on the trigger and firing code. I hope it's more to your liking. Again, you can fire as many shots as the powerup allows. If you press and hold the button, it will fire all of the shots at once. If you quickly press the button, it fires one shot. The amount of shots fired varies depending the powerup value and the duration of time the mouse button is held down.

If you would like to space out the laser more, just make a counter that checks the trigger every so many passes. I will let you figure that out by yourself.

New POWERUP Mods:
David_M_
19
Years of Service
User Offline
Joined: 27th May 2005
Location:
Posted: 11th Aug 2005 07:09
Thanks so much. I ended up adding a delay3 as part one of the IF conditions and got it to work how I liked it to. So simple I could have kicked myself. OUCH !!!
My next question is, when the bombs and lasers are moving across the screen they look line two that are touching or like they are stretched. The faster they travel the worse the effect. The slower the travel the more normal they look.
Why ???????

Thanks again.
D Ogre
21
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 13th Aug 2005 22:00
Well, Dave it's because the code is not really keeping track of the actual position of each laser. The firing is based strictly on timing. So, if you reduce the time for of the trigger delay, you are in effect reducing the distance between each laser. The more time added the bigger the distance. It's not an issue off stretching, but the distance between the pulses. Does this make answer your question?
David_M_
19
Years of Service
User Offline
Joined: 27th May 2005
Location:
Posted: 17th Aug 2005 14:22
Hello,
I just wanted to give an update of were I was at on the code.
I also think that the visual effect of things stretching or smearing or vibrating as they move seems to be lessened by putting something behind it other than just mostly black space. The more you specifically watch the lasers move, the worse they seem to smear or vibrate (I am not sure exactly how to describe it). That is what I ment by my previous question. I am working on a static background (stars and some planets) to make it look better. I think I have that worked out I just need to make a decent looking bmp for it. I will also need to renumber my sprites, due to not planning good enough of what all sprites would eventually be in the code. I will probably work on more power ups and maybe a shield for the ship.
That should keep me busy for a bit. So dont think I've quit, I am just working on stuff. Hopefully I can figure most of it out on my own.

Thanks again so much. Chat later, I'm sure I will need some kind of help again.
D Ogre
21
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 22nd Aug 2005 22:53
The visual anomalies that you are seeing are due to the pixel incrementation used for movement, and partially from the screen refresh (SYNC) rate. The larger the value used to move your sprites the more evident this will become. You could fine tune this by reducing the movement values and increasing the frame rate. There will be a limit to how much you can tune. This depends on the your computer and the finished build of your game.
David_M_
19
Years of Service
User Offline
Joined: 27th May 2005
Location:
Posted: 23rd Aug 2005 05:06
Thanks for the further input.
I regret to say that I have not got to work on the game much of late, but it is not forgotten.

Thanks again,
David

Login to post a reply

Server time is: 2025-05-18 00:37:07
Your offset time is: 2025-05-18 00:37:07