"Shoot an object" problem & another question
Hi!
1) My character collects an item. A variable is set to 1. He can shoot...the shot does not have collision detection. It flies through walls. I cannot apply collision detection that's why I use another method:
player presses fire -> set shot-object to 0/0 of player, set dir to dir of player etc.
The shot-object is positioned outside the playfield. It works but when I want to shoot again while shot #1 is still flying the first shot starts again at 0/0 of my character. I tried a solution with "player presses fire -> create shot-object" etc. but still the same problem...
How can I have multiple shots that can bounce off walls?
2) Apples, bananas, lemons all belong to my group 1.
If I collide with them they disappear (one of them).
When I get an apple, I should get 5 points...20 for a banana...how can I use groups in this case?
If character collides with group 1 => add x to points...but the cpu does not know which fruit I have just collected.
3) A similar question:
Players 1, 2, 3 and 4 all belong to my group "players".
Player 1 is controlled by joypad1, 2 by joypad 2 etc.
If player 1 collides with... he loses one life. "Subtract 1 from joypad1"...
Again, can I use groups? If one member of group "players" collides with... subtract one of ... does not work as the cpu does not know who is who.
Is there another solution apart from coding such events manually for player 1 AND player 2 AND player 3 etc.?
Re: "Shoot an object" problem & another question
Re: "Shoot an object" problem & another question
2: Set up an alterable value in all the objects in the frame editor saying how many points they're worth. Then in events editor, do:
Player has collided with group.group1:
-Player: Add Alterable Value A("group.group1") to score
-Destroy group.group1
Re: "Shoot an object" problem & another question
For Question 1:
I'm not totally sure of what you are doing from your description, but there are a couple ways you could do this. The easiest way using your existing approach is to make sure the bullet object is set to Bouncing Ball movement. This will give it a speed when the you "fire" it and also allows it to bounce when it hits something. So your code could look like this:
Player presses Spacebar
->Create Bullet at 0,0 of(Player)
->Set Bullet Direction to Dir (Player) [Note: this is under Animation -> Animation Direction in the Actions dropdown]
Then you need some collision events to make the bullet bounce:
Bullet collides with (object)
->Bounce [in the bullet column]
If you want the bouncing to be more predictable, you would have to probably use the Clickteam Movement Controller object and set the speed and direction manually using expressions. but that is a bit more complex.
Hope that helps you get started,
Mobichan
Re: "Shoot an object" problem & another question
Thanks but this does not work. If I shoot a bouncing ball it does not bounce anymore because of the event "shoot an object".
Re: "Shoot an object" problem & another question
If you want control of the object you can't use the shoot an object action.
You would have to create a regular object set its direction and movement and then you can get some control over it.
Re: "Shoot an object" problem & another question
But this means that I have to create bouncing ball 1, bouncing ball 2, bouncing ball 3 and bouncing ball 4 if a player has up to four bouncing shots in a level at the same time?
If two players fight and each of them can shoot up to four bouncing balls it will need many events. If player shoots and bouncing ball 1 is already flying and bouncing ball 2 is already flying then shoot bouncing ball 3 etc.
Re: "Shoot an object" problem & another question
Use the create object event instead of shoot an object and you won't need multiple objects.
Re: "Shoot an object" problem & another question
My code works because I tested it before posting. And it is only 2 lines of code. If you want to limit the number of shots per player, that needs additional code to stop the player from firing unlimited bullets. As Jeff said, you can't use "Shoot an object" in this case. Well, maybe it is possible, but it would get messy.
Basically, this code approach spawns a bullet in your game at the position of the player and then it becomes an independant entity with its own behavior. Every time you spawn a new bullet entity, it will act on its own.
Mobichan
Re: "Shoot an object" problem & another question
Mobichan I cannot get it to work.
I can shoot the bouncing ball but when I shoot again the same shot is used again...it starts again at 0/0 of the player. It does not launch a new ball.