<Solved> How to improve and simplify code

Get help using Construct 2

Post » Fri May 15, 2015 2:19 pm

So as you can see from below, I code like a Neanderthal,
so I am asking how to improve my code and make it more efficient;

You can see from the image, I want to increase the number of sprites being created as the Difficulty ( global variable) number increases.
Image
The way I did it works but I know there is a more efficient way to code this,
I just don't know how,
please show me an actual example.

Much and many thanks
I really appreciated it.
Last edited by producermark11 on Sat May 16, 2015 3:50 am, edited 2 times in total.
B
36
S
10
G
4
Posts: 250
Reputation: 7,963

Post » Fri May 15, 2015 2:26 pm

I would say use Functions and pass the number of objects to create as a parameter.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
86
Posts: 5,416
Reputation: 59,518

Post » Fri May 15, 2015 2:28 pm

@zenox98
Can you show an example image? ................ please. :oops:

I am trying a Function but I am failing to see how this makes it more efficient,
maybe I am doing something wrong. :mrgreen:
B
36
S
10
G
4
Posts: 250
Reputation: 7,963

Post » Fri May 15, 2015 2:46 pm

system trigger once (although this should probably be triggered by the event in which Difficulty is changed)
> call function "spellspotCreate"

on function "spellspotcreate"
>spellspot destroy
-- repeat "Difficulty+3" times
> create object spellspot at (100,100)
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri May 15, 2015 3:26 pm

Not perfect, but close enough

I would also use params, but I didn't have the time :( About to get loadshed (Our South African Idea of Fun)
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,718

Post » Sat May 16, 2015 3:39 am

@DUTOIT
That's exactly what I was looking for,
(an actual example, (as my skill level isn't high enough to understand a few brief sentences ))

I can work with this.
Thanks so much.

and thanks to the other posters as well.
Much Appreciated.
B
36
S
10
G
4
Posts: 250
Reputation: 7,963


Return to How do I....?

Who is online

Users browsing this forum: ignaciosimo, nickar and 47 guests