Okay, I need a game where the main character (MAIN) has a gun he carries around. When the "F" key is pressed, I want him to fire it. The problem is getting the bullet from point A to B. What I want if for when the F key is pressed, an animation is run showing the character pointing the gun right, then a bullet shooting from it and traveling right across the screen, always at the same Y position. I thought I could do this by altering the bullet character's (BULLET) "x" position by +1 then wait(1) in repeatedly execute, so that the bullet would travel right across the screen at a decent speed. The main problem is that I cannot figure out how to get the bullet right on the main character's sprite and beside his gun to make the bullet appear to come out of the gun. I cannot get the bullet to the character's gun's position. Any suggestions or a different way to do this???
I would make the bullet sprite the same width and height as the MAIN character sprite, with (of course) most of it transparent, put the bullet itself just behind the MAIN sprite's gun, then with a simple MoveCharacter() you can send the bullet moving... Thats just one way...
hmmm....sounds good. Just a little problem though, when the bullet's sprite (though most is transparent) comes into contact with an enemy sprite, even though only the transparent sprites touch, the game will still run the interaction for AreCharactersColliding(BULLET, ENEMY)==1 but to th player, it will look like the bullet missed but still hit the enemy. Also, I am unaware of how to set the coordinates of BULLET so that it will be at the same place that MAIN is.
Quote from: Akumayo on Fri 26/11/2004 16:20:32
hmmm....sounds good. Just a little problem though, when the bullet's sprite (though most is transparent) comes into contact with an enemy sprite, even though only the transparent sprites touch, the game will still run the interaction for AreCharactersColliding(BULLET, ENEMY)==1 but to th player, it will look like the bullet missed but still hit the enemy. Also, I am unaware of how to set the coordinates of BULLET so that it will be at the same place that MAIN is.
First part, Are characters colliding checks if the x,y position of the bottom middle pixel is the same, so actually unless the enemy sprite is really small, it will be closer than if you use a small sprite for the bullet, if you use a small bullet sprite you will have to hit near the feet of the enemy...
To set the bullet to the same coords as MAIN is 3 commands
character[BULLET].x = character[MAIN].x;
character[BULLET].y = character[MAIN].y;
character[BULLET].room = character[MAIN].room;
and there ya go...
Thank you so very much, many thanks truly, I will reply if anything goes wrong but this looks very good.