Removing a drawn pixel
Removing a drawn pixel
Hey, I'm quite new to DirectX and I've found Chili's Framework very helpful. I've made just a simple Space Invaders game to test myself, and I feel I've done OK. However I'd like to know how to remove a certain pixel if a condition is met. (In my case, if the Enemy reaches the player or the missile reaches the Enemy/Top of screen). I'm using the PutPixel command, so I'd be grateful if anyone could tell me how to achieve this.
Re: Removing a drawn pixel
Sounds like you mean collision detection. The simplest way is to make a box around the enemy and then test every frame to see if the pixel is inside the box. Also, to see if the pixel has gone past the top of the screen you just have to test if the Y coordinate is less than 0.
Musi
There are 10 types of people that understand binary.
Those that do, and those that don't.
There are 10 types of people that understand binary.
Those that do, and those that don't.
Re: Removing a drawn pixel
Alright, thanks I fixed my previous issue with your help, however I would like to know how to have it so when I press space once, it places a pixel above X, (and doesn't keep updating its x position) and keep moving upwards. I made a Boolean which sets itself to true once space is pressed, however then when I store the X position of the player into another variable, it keeps updating, because the Boolean is set to true. Any idea how to go about solving this?
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: Removing a drawn pixel
There are two states for the keys pressed and released so maybe you could use an if statement that;
That way the PutPixel line will be skipped if the spacebar is not pressed.
Code: Select all
if(SpaceIsPressed)
{
PutPixel (?,?,?,?,?);
}
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Re: Removing a drawn pixel
Hmm, can't say why the new X variable is updating without seeing the code. If i have to guess, id say you're making the pixels X coordinate = players X coordinate every frame when it should only be done once when its created.
Musi
There are 10 types of people that understand binary.
Those that do, and those that don't.
There are 10 types of people that understand binary.
Those that do, and those that don't.
Re: Removing a drawn pixel
Thanks, I fixed it by initializing it outside of the Loop with your help.