Handling 4 Players. Combine Events

Discussion and feedback on Construct 2

Post » Fri Nov 08, 2013 6:34 pm

Here's an example file you can see how i've delt with reusing assets and spawing "prefab" characters based on one setup and multiple controls

Basically its all based on functions though.

You create a single player entity, and give it a unique owner ID at the time of creation. Then program a function for each different type of attack or movement etc.

Then you call the function using its Unique ID as a parameter, and thus only the player that matches that Unique ID performs the action.

eg: On Function Fire Bullet (1) (100) (250)


Function "Fire Bullet"
create object "bullet" at function.param(0) (player 1's position)
set bullet.damage = function.param(1)
set bullet.speed = function.param(2)

This way you can reuse this one section of code over and over for any player no matter how many you have etc.

Example
https://dl.dropboxusercontent.com/u/403350/SpawnPlayerExample/index.html
click player 1 and player 2's) gamepad to spawn them.

use WASD and SPACE for player 1 and arrow keys and "/" For player 2

you can see how i've used the same technique for dealing with other ares such as collision detection as well, one function that gets reused over and over

Capx
https://dl.dropboxusercontent.com/u/403350/SpawnPlayerExample/SpawnPlayerExample.capxjustifun2013-11-08 18:37:52
B
87
S
44
G
16
Posts: 1,002
Reputation: 17,932

Post » Mon Nov 11, 2013 5:47 pm

Allright guys I got pretty much uf my stuff to work.

I worked with sub-events like @lennaert in your example. Thanks for sharing.

@justifun I can't have a look at your capx because of a missing plugin but i'll definetly check it out later when i have more time.

@jayderyu I finally had the time to finish it.

This is what I came up with for my cooldown behaviour:
Live Demo

with these little events I achieved more or less the best cooldown system i ever had xD I didn't test it on a mobile device for multiple touch inputs at the same time but i really hope it works lol
(edit: url did not work for some reason)

CAPX

EDIT: ignore the animation frame for now. It does not reset properly, If you have a good solution feel free to write me.

This is the new array which i store almost all information about players in. (edit: url did not work)


y0 - player number
y1 - wheather a shoot button is on cooldown or not
y2 - custom cooldown time, can easily be reduced on kill
y3 - amount of degrees I change the bullet.angleOfMotion while a movement key is in touch.
y4 - bullet.speed of each character .. very easy to change if someone picks up a speed power up for example.
y5 - player kills ...
y6 - bullet speed ..
y7 - animation / "skin"

and so on ..

this is my movement example which i also reduced the events a lot.

Live Demo

CAPX

If you have any questions about the array just ask.

cheers!
phil
11.11.13philx2013-11-11 17:56:25
B
23
S
6
G
5
Posts: 132
Reputation: 4,487

Post » Mon Nov 11, 2013 7:00 pm

nice one :D and your welcome


Might I add a suggestion,stuff each control in a corner ;)   max space usage, more comfortable playing.
You could also ponder placing it on the center of each side, but it would give an unequal devide.

lennaert2013-11-11 19:01:13
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,567

Post » Mon Nov 11, 2013 8:38 pm

[QUOTE=lennaert] nice one :D and your welcome


Might I add a suggestion,stuff each control in a corner ;)   max space usage, more comfortable playing.
You could also ponder placing it on the center of each side, but it would give an unequal devide.

[/QUOTE]
@lennaert
Thanks for your suggestion. Have a look at the "second version" Live Demo in my Main Thread This is how the controlls are going to be placed.

By the way! Has someone a good Idea how I could manage the spawn system? where should the characters spawn after death? random? with spawn protection? or would it be better to play like elimination .. without respawn wait untill the last one is left, he gains the most points and then the next round starts.. ?

@jayderyu how do you spawn players in your game?philx2013-11-11 20:38:45
B
23
S
6
G
5
Posts: 132
Reputation: 4,487

Post » Mon Nov 11, 2013 9:43 pm

Well in my game all the players are a
SpritePlayer with a PLAYER_ID variable.

I create the player. Set the ID. then create and pin the visual part of the player. If the player is complex with lots of sensors. Then it's a big list of positioning and pinning the sensors to player.
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,018

Post » Tue Nov 12, 2013 6:37 am

@ phlix, haha, yeah I think you already had the same idea :), liking it

As to spawning and where, perhaps have that related to game type.
ie normal mode: players spawn in their respective corner, crazy mode randomized :)
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,567

Post » Tue Nov 12, 2013 9:40 am

[QUOTE=lennaert] @ phlix, haha, yeah I think you already had the same idea :), liking it

As to spawning and where, perhaps have that related to game type.
ie normal mode: players spawn in their respective corner, crazy mode randomized :)[/QUOTE]

Yes we had :D thank you for you feedback.
I think I'll go with a corner spawn and spawn protection in normal mode and then in crazy mode i'll try something like round-based game where you don't respawn and when there's only one player left the game will move on to a further layout where you can improve you stats like Speed, Handling, Bullet speed, Rate of fire ... and so on, based on the amount of kills you did last round. So the first round everyone will be very slow and it's hard to evade bullets and then round afer round you can choose what you want to improve ..

In my previous versions i always let the player die if he went out of the layout but I'm thinking of aligning the layout border with solid sprites and give the players the behaviour "bounce of solids" .. What do you think about that?

In later updates after the game has been released, I want to make expensive special upgrades where you can buy for example a upgrade that let your bullets bounce of walls etc.
B
23
S
6
G
5
Posts: 132
Reputation: 4,487

Post » Tue Nov 12, 2013 4:32 pm

Would be good to have some sort of bounce effect on the walls, perhaps even something like a moment of disorientation :)

Upgrades are always good, here is a suggestion for a few: faster turning, ammo amount

Also, got a suggestion for you making the level of multiple players more fun to experience results of their play:

When there are 2 left, make a special moment:

IE: second person died, then:

the screen goes just a little bit darker, apart for a spot in the middle, with on each side on of the players, perhaps slightly zoom in, add an exciting tune like something is about to happen: and then have the two fight it out ..   Sudden death moment.

It perhaps doesnt mean much, but that moment of special battle could be where the players are aiming for to end up :D



lennaert2013-11-12 16:32:47
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,567

Post » Tue Nov 12, 2013 7:30 pm

[QUOTE=lennaert] Would be good to have some sort of bounce effect on the walls, perhaps even something like a moment of disorientation :)

Upgrades are always good, here is a suggestion for a few: faster turning, ammo amount

Also, got a suggestion for you making the level of multiple players more fun to experience results of their play:

When there are 2 left, make a special moment:

IE: second person died, then:

the screen goes just a little bit darker, apart for a spot in the middle, with on each side on of the players, perhaps slightly zoom in, add an exciting tune like something is about to happen: and then have the two fight it out ..   Sudden death moment.

It perhaps doesnt mean much, but that moment of special battle could be where the players are aiming for to end up :D

[/QUOTE]

Great Ideas! thank you for your input.
faster turning i already got on my list (agility/handling).
I wrote everything down and I will check how much effort it is to create those things. I like your point about the desorientation and i'll definetly do that since it's not that hard to implement.

The sudden death moment is something about the gamer's experience which I didn't really give a lot of thoughs on. Maybie I underestimated the importance of that. I will create this with an update at the latest.

But this is something I haven't got a lot of experience with. I want to make an animation for a double kill aswell that there are short lightenings all over the screen for 1 second. I'll have to experiment with those visual effects a bit.
And I can't imagine yet how to set up a proper "coded" trigger when someone achieves a double kill .. but we'll see about that.philx2013-11-12 19:30:33
B
23
S
6
G
5
Posts: 132
Reputation: 4,487

Post » Sat Nov 23, 2013 4:59 pm

Thanks
Check out my latest game RAPID-TAPIT. Get your Fingercise on with this one. A steady Tap is all you need to score points. Lift a finger and see what you can do...

Image

ALLMarkMade Designs
B
32
S
15
G
3
Posts: 356
Reputation: 5,269

PreviousNext

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 11 guests