tarek2's Forum Posts

  • chrisyamao

    Probably you spot it already by now but I will mention it just in case, I forgot to reset the Global variable "StarsAngle" to (0) other ways it will keep adding the numbers to the "StarsAngle" and it will keep getting bigger the value unnecessary

    So in Event 3 you can just add one more action to reset it to 0 before destroying the enemy

    Mouse>> On left clicked >>on enemy

    SubEvent Repeat 5 times

    Actions: set "StarsAngle" To 0

    Actions: Destroy enemy

    That will keep the variable between 0 to 360 Max

  • chrisyamao

    Cool Buddy

  • When you start and empty projects the last layer at the bottom is set to "Transparent" = No by default

    And if you create a new layer after that it sets that new layers the "Transparent" = to yes

    so when you add new layers make sure after go to the last bottem layer and set "Transparent" = No and all the layers that are above that set them "Transparent" = Yes

    you can do that by click in each layer and on the left properties Panel look for "Transparent" and set it to Yes or No

  • Hi dwtiger

    I had some time free and I thought to give you a hand so I organized your capx and modified it a little bit, I touched only "Event sheet1"

    The purpose is to help you understand how to Link and Pick objects, and to better plan and optimize your events using different behaviors instead of overlaps and that will help you also in saving some Memory as you will not need to use to those big images for your enemies etc......

    Important Notes:

    Containers:

    In this Example, I use "Containers" because it's much easier to link objects with his parents or saying it differently we use less that Variable "BelongsTo"

    Here is the link to the Manual to understand more about Containers

    https://www.scirra.com/manual/150/containers

    Waits:

    "Waits" Are replaced with "Timers" Thanks to 99Instances2Go Tutorials and Help and warnings as they can cause many problems for the lack of desynchronization a simple Example: if we wanna fire up bullets every 0.2 seconds, doing it with waits it can end up in some points firing up two bullets at the same time and we don't want that

    Timers Link: https://www.scirra.com/manual/167/timer

    Functions:

    And Last I used "Functions" to better organize the events and because you can scale it up easier by adding more enemies so you will just need to modify The "Functions" and add the new Enemy to the "Family Enemies" and if this new enemy does have different Abilities or fire rate etc... just change his variable "Im_The" to what ever name you want so you will have it much easier to identify when you pick through the Functions so you can apply different abilities

    Manual: https://www.scirra.com/manual/149/function

    Some Useful Links:

    https://www.scirra.com/manual/142/families

    https://www.scirra.com/manual/75/how-events-work

    Heyy is not the best job but the purpose was more to have an overview of how everything that I mention above works, let me know if you have any questions, the capx I left it with no comments on purpose so you can study it to see how everything is linked together is the best way to learn, I hoppe it helps you

    Capx: https://www.dropbox.com/s/2uplqmxse9ky4mf/WithContainers1.ver-r244.capx?dl=0

  • Thank you so much! Hopefully I'll be on a clear path to finishing this game... Eventually. I don't think I could've fixed this on my own!

    Yw sir,

    cool that you are back on track

    Good luck with your game, you doing really well man keep going, One thing I will do before you go further with your project and it gets much bigger and messy you will have a hard time to find bugs, so I recommend you to stop for a few hours just to organize your code in groups before is too late, and look for things where you can optimize them

    example:

    Why use an enemy size of 280x280 when his actual size is just 36x36 ?? you are wasting x8 times more memory for each enemy when you could just put 36x36 and use the Line of sight to see if the enemies are in the range of the Player like you do with the overlap but cheaper. you will save memory and collisions checks

    Read this very carefully:

    https://www.scirra.com/blog/112/remember-not-to-waste-your-memory

    Another thing remember to keep testing performance to see if you are doing something wrong that can hurt you performance

    Create a layer call it "HUD" then click on that layer and in the left panel look for parallax change the (100,100) to (0,0)

    Now create a text in that layer HUD

    And on the event sheet add

    Every Thick: >>Txt >>set txt >>to >> "Fps: " & fps & newline & "Cpu: " & round(cpuutilisation * 100)

    so with this, you will see the fps and cpu on the screen all the time while you testing

    And here is a link for some info about Groups:

    https://www.scirra.com/manual/80/groups

  • yeah tried those, the bullet just goes to the 1st hitbox

    https://www.dropbox.com/s/9mty0n1b2sx1cvr/RPG.capx?dl=0

    I'm not sure what I'm doing wrong

    Event 12

    On the Action, you didn't choose the Family you choose the object of that family,

    you moved the sprite10 towards the (Hitbox = Object) is wrong you should move the sprite towards the (Family = Hitboxes)

    just replace (Hitbox.X, Hitbox.Y)

    by (Hitboxes.X , Hitboxes.Y)

  • Thanks! I've fixed all of those except one, I can now kill enemies one by one, but my bullets keep going to the first hitbox, how do i specify which hitbox i want my bullets to go to, cuz i want them to go to the nearest enemy hitbox.

    ????

    Did you try the example that I left in my pictures ???

    Because is working for me

  • dwtiger

    Again the same Mistakes Event 13 >> the action to add 1 to the enemy DamageTaken you add it to all of the enemies because you don't specify to which enemy belongs that hit boxes That's why you kill all the enemies in one go.

    And Event 14 have no actions in there so whats the point to put a condition without any actions on it??

    it should be like this

    Picture:

    And You did the same thing on Event 84 & 85

    Event 87 Again take damage to the enemy but which enemy all of them?? and event 88 empty why you keep leaving empty events with no actions???

    Bullets Problem:

    Event 11 you overlapping the enemy so it adds that enemy to the pick list but on the action you creating the bullet and then you move the bullet to a HitBox but the hit box is not in the pick list you don't specify to which hitbox belongs to that enemy, therefore, is an Un-Referred Object so C2 it will pick up the first hitbox created wich is Hitbox = 0

    So first replace the sprite is overlapping to >> "The Family Enemy"

    Then sub event of this event>> "Family hitbox" >>Compare>> belongsTo = To >>Enemies.UID> > Action then you can move the bullet to that angle hitbox

    Here is A picture:

    Then again you will have the same Problem with the other bullet >> Sprite36 if you don't change it, In Event 83 so do the same as above

  • dwtiger

    First please go to the debug option from c2 button and check at the left panel where it says "Hitboxes" & "Hitbox" watch the numbers now go near to any enemy and stay there and look again what happens with the numbers, you creating hitboxes none stop

    75 and 76 are the ones causing the problem, you see I warned you in my first post if you are not careful with overlapping things like this will happen, normally creating 1 object the way you do it using overlaps you always add the >> Trigger once> you can find it in the system.

    But there is another problem with this you creating already all the hitboxes on the Start of the layout Event 81 remember? so you really don't need event 75 & 76 that will create extra hit boxes for the enemies and it brake the code, an less you don't wanna create the hitboxes at the start of the layout and you wanna create them only when the player overlaps the enemy, in that case, you have to move the last three actions from event 81 to wherever place you create the

    hitbox example event 75 and adding the >> Trigger once>

    Event 81 >>replace the system create object by >> Enemies >>Spawn object>> Hitboxes and leave it in the same place order were it was the old one, I'm not sure why but it was creating the two hit boxes in the same place, but the spawn option it should fix that

    Event 84 >> you have Action destroying an Enemy but you should be destroying the Hitboxes

    Event 17 and 18 you don't need it because you already destroy the Enemies on Event 82

    Tips:

    -The Pin behavior if enemy doesn't move you don't need it

    -Remember that you have the behavior >>Line Of Sight and you can use it instead of checking for overlaps for everything

    -you have the bullet behavior for the Bullets swell

    -you have the groups to organize the code into groups and name them will help you to find bugs quicker

    probably I forgot something if I remember anything I will post it

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • dwtiger

    No problem man, glad to help

    here is a capx that you can open with the c2 version r244

    https://www.dropbox.com/s/otapg6806888ltg/Health%20bar%20version%20r244.capx?dl=0

    now this capx is for the health bar only but it should be exactly the same process to create the hit box for the enemies.

    Just in case that you cannot open the capx, the basic idea will be:

    first, put the hit box in a family and lets named Hitbox and to that family add an instance Variable lets named >>BelongsTo >> plus add swell the Pin behavior to that family

    second, put your enemy in a family and named example enemies and add an instance Variable lets named MyUID and another variable >> Health

    Note: the tree instances Variables (BelongsTo, MyUID and Health) are variables type >> Number

    Now let's do the events side: one more Note before we start >>when I say sub event means right click in the top event that we currently working on, and select >>Add>> then >>Add sub-event

    let's start, the first Action will be created the hitboxes at the start of the game and Link them to their enemies

    1- On the start of the Layout: >>Action :>> chose the family Hitbox >> then destroy

    now sub event of this event>> For Each >> choose the family enemy >> now the Actions> goes in this line not in the top event

    >>>Action: chose family enemy >> set variable >>MyUID to >> self.UID

    >>>Action: system>>create "hitbox family" >>on layer (you choose)>> at> enemy.X, enemy.Y

    >>>Another Action>> "hitbox family">> set Variable "BelongsTo" >> to >>enemies.UID

    >>>Another Action>> "hitbox family">>Pin to enemies

    Now with this, we finished the initial preparation, so how do we refer the enemies and their hitboxes?

    2- Create New event: sprite10 >> On collision with >> "Hitbox family" >>Action: destroy sprite10

    Sub Event of this event: >>enemies >> compare var >> MyUID >>Equal to >>hitbox family var: BelongsTo

    Action: in the same line of the sub : enemies add or substract (Amount ) >>from enemies >> Health

    3-Create New Event: >>Enemies family >> Health >>is equal or greater than 10

    Sub Event of this event >> For Each >>enemie family>>Action Destroy

    Sub event of this Sub event >> hitbox family>> var BelongsTo>> is equal to>>

    Enemies Family>>var MyUID: Action >> Hitbox familie >> destroy

    That's it Let me know if you have any problems, Make sure you put All the Actions in their correspondent line if is top event actions you put them at the top if is a sub event actions put them in the sub event if is for a sub sub event then the same put them there in the sub sub event other ways you will break the code

  • dropbox.com/s/itmt0kmsks26jau/RPG.capx

    YAOOOOO man that was so many events lol I got lost, normally you clean and share the minimum events enough events just to reproduce the problem with destroying enemy

    Anyway there is so many things there that need serious optimization and I haven't got time to check it I should be sleeping by now

    first, let's talk about the problem>> destroying enemy

    on event 13 you have

    Sprite10 is overlapping Hitbox

    Action> Sprite10 destroy

    Action> ad 1 to Enemy health

    1-You see the problem here you don't reference to which Enemy belongs the Hitbox so because of that it picks all the enemy's and add 1 to each enemy health, you see that's why you kill all in one go

    2-another thing that you need to change is instead of the overlapping use on collision is better why you don't use sprite10 on collision with enemy >> Action sprite 10 destroy, add 1 to enemy health that's it more simple

    but if you gonna use overlapping you should use trigger once so it runs only once not every thick

    you have the overlapping condition every where without the trigger once that it will cause you a lot of problems, normally the things that they need to run just once add the trigger once but if need to be constantly true then don't add the trigger once like event 73 and 74

    3- when you wanna check for the health to destroy enemy's is

    enemy health is bla bla

    For each enemy: destroy <<<<<<<<<you see is for each enemy not >>for each sprite >> because here you

    have referenced the player sprite not the enemy

    That's a few things that a quick saw I didn't check everything but you should really check everything and optimized

  • can you share your capx I will quick have a look

    ok I can see your picture now , use families will easier and better performance if you have many enemies

    it looks like you adding to the health instead of subtracting

    Try this then

    health >>is equal = or more than 10

    subevent >> for each enemy >> Action Destroy

    here is the pictures from my events

    https://www.dropbox.com/s/hemg3o2wapsloau/Health%20bar%20pic.png?dl=0

  • I have the screenshots here (also i have the variable for enemy damage taken as health, planning on changing it soon.)

    http://i.imgur.com/Jln4vhI.png

    you can install the beta or you can

    right click on my capx extract it with winzip

    it will give you 4 normal folthers and one extra black that it looks like the capx with diferent name

    then you right click in that new black capx and open it with notepad

    then look for this <saved-with-version>24500</saved-with-version>

    then just change it to your version and then save it, after that you will be able to opn it

    example if you have the r244 version then change the <saved-with-version>24500</saved-with-version>

    to the version <saved-with-version>24400</saved-with-version>

  • Is the beta version r245

    https://www.scirra.com/construct2/releases