Some How to's for my game.

Get help using Construct 2

Post » Tue Apr 17, 2012 8:20 pm

Hello everyone.

I'm new around here, although I've been reading some tutorials and trying some stuff out.

I'm actually working on a game. It's an arcade game, in perspective.
Some friends are working on the artistic part of it, so I am currently working with own-made boxes.

Basically, I have an area, surrounding my player character (pinned to it), and if an enemy gets into the area, it should react by shooting at me, and moving towards me.

The problem I'm having is the following one:
When an enemy enters into my "area", ALL the enemies start to shoot me, while I only want to shoot me the one inside my "area".

How can this possibly be done?

I've settled a health counter for the enemies, which work great, and it's independant for each enemy, but I've tried adding a boolean, which settles if it's inside the area, or not, but still, while doing so, all the enemies attack me.
It's like that boolean would be linked to them all, and would switch for them all at the same time.

Also...and I'm currently working on this, how can I make the enemies to shoot at my position, instead of "straight".

Thanks a lot for the help provided,

Miyavi

Get the capx

Edit:
Already managed to shoot at my position.
Also added a decreasing life bar, but it's anchored to the screen, and if you realise, whenever you move, it vibrates horizontally.
How could I solve this?

Also, link to playable content

Edit2:
I already solved enemies chasing me.
Yet, I have no clue on how to make the enemy that enters my active zone (and not them all at once) to chase and shoot me.
Any helping hand out there? :)

I guess it has to be done with UIDs, right?Miyavi2012-04-18 01:03:18
B
6
S
1
Posts: 54
Reputation: 958

Post » Wed Apr 18, 2012 7:43 pm

No one could help me out?
B
6
S
1
Posts: 54
Reputation: 958

Post » Wed Apr 18, 2012 8:20 pm

the .capx doesn't work can you re-upload , also i would say try to put enemy veriable for example put (enemyattack-false)
so when the enemy collision with player-area attack put the enemyattack-true.
and put event if enemyattack true = enemy will attack,change direction...

try it maybe it will fix ^^ if not try to use array (array 100% can fix this but im not good in it)!
B
48
S
15
G
6
Posts: 795
Reputation: 12,035

Post » Wed Apr 18, 2012 8:58 pm

Sorry, I re-structured my dropbox yesterday, and forgot to upload the new .capx

Here's the new one

Also, I've tried doing what you say.
I declared an instance variable for enemy1, which is a boolean, and I switched it on when they collided with my active zone, but it was just the same, every enemy would attack me, although they weren't in my active zone, so it's like all their boolean var would switch at the same time.

I haven't looked into arrays nor UIDs yet, but AFAIK, every created object has a UID, so I could store the one colliding to my player's zone in an array.

I'll have to look it up.

Here's the new playable content, too.

Greetings,

Miyavi.
B
6
S
1
Posts: 54
Reputation: 958

Post » Wed Apr 18, 2012 9:13 pm

Event 13, replace "System every tick" by "Enemy1 is zoned" (is boolean set) helps with picking only the zoned enemy and so you're only followed by enemies at range.
As soon as the enemy is not in your range anymore, it stops.

Event 18 add also a "Enemy1 is zoned".



The problem here was about picking, picking only the correct instances and that's the backbone of C2.

Check the How do I FAQ and check the section "Picking/Selecting instances" and review the items listed there.
The threads contains all the explanations one might require about picking.Kyatric2012-04-18 21:14:08
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Wed Apr 18, 2012 9:21 pm

Wow, thanks, Kyatric... so it was me, not doing it correctly.
I'll check those threads right now.

By the way, is there a way to change an object name, so it updates the actual "code".
I mean, if, for example, I decide to change my "enemy1" name to archer, could I do it so I don't have to manually change everything on the actions/events? (As done with search and replace, in usual programming)
B
6
S
1
Posts: 54
Reputation: 958

Post » Wed Apr 18, 2012 9:40 pm

@Miyavi, I'm not sure if it's exactly what you're referring to, but C2 automatically renames all occurrences of an object in the event sheet(s) when you change the name of the object. It's one of the things you really have to love about C2!
B
126
S
7
G
4
Posts: 185
Reputation: 7,233

Post » Wed Apr 18, 2012 10:15 pm

Yeah, I meant that.
I didn't try that out, since I wasn't in the need to do so, but it's nice to know, if I ever need to do it (which I will :P)

By the way, what about making a class which entends from another one?
For example, I have enemy1, which is an archer, indeed.
I want to have a class "Enemy", and some types of enemies, who will extend from Enemy.Miyavi2012-04-18 22:18:03
B
6
S
1
Posts: 54
Reputation: 958

Post » Wed Apr 18, 2012 10:34 pm

There's a way to do so with the families feature (licensed version).
I haven't yet tested how to, and I don't recall having seen documentation about this yet, but it should be easy enough.
That's what Ashley has implemented, as closer to the class system of coding language, in C2 I think.

There are other possibilities to do so anyway, they require more events/setup though.
Generaly I'd advise to use an array, store the values/characteristics of your "class" there and apply those values to newly created instance "Enemy" making it of said class on creation.

I made this commented capx some time ago to answer a similar question.
It's not the exact principle of class as in coding language, but it does the trick "C2's way" I think.

Hope it can be useful to you.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Wed Apr 18, 2012 10:49 pm

Thanks Kyatric, I'll check it up.

I'm actually implementing a timer and score based on the level left time, nothing too fancy :P

Is there any way to freeze the game until, let's say, I press a button?
In my game, if I die, the enemies keep shooting at something, so I want to freeze the game.
B
6
S
1
Posts: 54
Reputation: 958

Next

Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 21 guests