nimos100's Forum Posts

  • This might help:

    [quote:2kl0g2sr]Since I just made a very simple example of a function and how to call it in another post. Ill add it here as well, as functions are actually very easy to use, the moment you get them.

    1. Add function plugin

    You first have to add the function object to your project. You find it in the list where you also add mouse, keyboard etc.

    2. Create a function

    Once the plugin is added it will be available for your whole project. To create one you add it like you would any other event. And you have 2 options to choose from:

    "On function"

    "Compare parameter"

    For now you only need "On function" and this can be compared to adding an "On mouse click" event, but instead of "On mouse click" already being added for you, you can decide what it should be called, and when to trigger it, which is done by calling it.

    So after you select the "On function" you will be able to give it a name.

    "Name" is just a reference so C2 know which function you are calling whenever you do a function call. So you can make it whatever you like.

    In the above example I want the function to give me the license plate of a car. So giving it a name of "Get car license plate" describe what the function does so I can remember it. But in theory I could have called it "Moon rising" and still make it return the license plate of a car.

    3. What a function does

    Now that you have added a function it will be empty and not very useful. To make it useful you want it to do something for you. And you can see a function like a machine you put something into it, and it does something and then it might throw something out.

    In the above example I throw in a car, and I want the function to give me the license plate of that particular car.

    Input = Car

    Output = license plate

    4. Calling a function

    A call to a function is an action, so like you would set the text of an text object, you will make the function call as an action.

    When you press "Add action" you can again select function, but this time you will have two other options "Call function" and "Set return value". Since we need to call a function you just select "Call function"

    And again It ask you for a name. Now this name need to be the name of the function you want to call. So in this case "Get car license plate". This will make C2 aware that this is the function it should look for.

    5. Parameters

    In this window you can also add parameters. Which would be the input, so in our case we want to throw in a car, since we want the license plate of a car. We need to tell the function which car we want the license plate from.

    So if you press "Add parameter" there will be added a field called "Parameter 0" These names are locked, so you can't change them. But you need to be aware of the order in which you add them. But for now since we only need 1 it doesn't matter.

    Since we want a specific license plate of a car, we need something that is unique for a car. So the UID of the car objects works very well, as its unique for any object. So we throw that into the parameter 0.

    6. Make the function do something

    So now the function call is ready and will do what it is suppose to, however since our function is empty it doesn't do anything.

    So the first thing we have to do, since a function isn't that clever even though we have already thrown it a "Car object" it still doesn't know what that parameter is for. So to make sure it knows, we add:

    "Car pick instance with UID function.param(0)"

    Since we stored the UID in parameter 0, we can also use it to select a car which match this UID. Now the function know what car we are talking about.

    7. Return value

    The same way as we added the function call, we now add an action of "Set return value", when you add it you get the possibility to set a Value. This is what will be returned when the function is done, doing what I does. In our case we want it to simply return the license plate of a car.

    Since we have already told it what car we want the license plate of. We can simply set the return value to "Car.license_plate"

    8. Using the return value

    Now that it have returned the license plate we want to use it for something. So what we can do is to check the return value and then act on it.

    In this case we want to check if the returned license plate is "12345678" and if that's the case then do something.

    That is the basic of using functions and in this example we returned a license plate, however its perfectly fine to not have a function return anything.

    When C2 reads your code and it gets to a function call, it actually jumps into that function, and will not continue reading your code, until it gets back from the function. So you could actually add everything that are in the function instead of the function call, and it would be exactly the same.

  • If I understand you correct you have 20 heads with different width and 40-60 hair options which are also different width and you want these to match any of the heads no matter what width?`

    If that's the case I think you might be overcomplicating things a bit, if each type of head have a hairline image point you should be able to just set the hair types image point to that image point and then you change the width of the hair to be equal to the head width. Just be sure that the image point is in the centre of the sprite.

  • You do not have permission to view this post

  • Hey, great game so far. How did you go about constructing the world map? I gather it's not randomly generated. Are you using a very large tile map?

    No, the world map is just a very large tile map that are "hand painted" (62500 tiles), this is only the base terrain like grass, rivers, roads, mountains, hills and so on. And I would like to add some lore into it as well, so if it was random generated i think it would be quite hard. Then I automate a collision map, so some tiles cant be move on, and tiles with road are better than those without and so on. And all resources and dungeons are randomly generated as well.

  • wow looking great!

    Thanks

    Finally having fixed the character sheet, I started working on the tactical part of the game and its going to take a while before that is going to be finished, as I don't really have a lot of content made for this part in regards of monsters and clutter, so have to make some objects for this, so I can do some testing, as I want to make it so each room are randomly generated, and hopefully make it so clutter can be placed in a way that they make sense. But to be honest I have no clue how to do that. But I have some ideas of how to do it, so hopefully it will work.

    Also I aim to make it so clutter is more than just graphics but so some can be used for cover, some improve stealth like carpets and others like light sources will reduce it. Would also like to make it so certain clutter block line of sight and so on. But the main idea is that the player and the monsters (Hopefully) can use the environment for there benefit during fight, so the fights will be a lot more tactical than just point and click.

    However so far I have manage to make it so rooms can be randomly generated in whatever size and shape needed, so they aint always just a square (Screenshot below is just a setup, and not a generated one). So at the moment im just making some random clutter, which I can use to make the clutter generator.

    Here is a screenshot of a setup just showing how it looks so far.

  • Don't think its easy to make one either, but it could be good training. However you could try something else than to program it an that is to make it learn from experience. Might not be easy either but how it could work is like this.

    1. You program all the basic rules for each piece, the ways they can move.

    2. You make a system that track all its moves and the player moves.

    3. Then at the end of the game if the computer won, you add +1 to all the moves it made, and if it lost you give each move a -1 in relation to what the player moved.

    4. And you keep updating this list so each time the computer plays you make it prefer moves that made it win earlier and try new moves if there are only bad ones in the list.

    5. Hopefully after a lot and lots of games the computer will be unbeatable as it know all the good moves in any situation....

    Whether It works I doubt but could be fun to try.

  • [quote:217x3kfl]Jobs.Get(str(round(random(1,6))))

    All of the possible jobs will sometimes appear as text but I also sometimes get a 0. This happens with other dictionaries too.

    Sounds weird the dictionary returns 0 if something doesn't exist. Have you checked the debugger to see that it actually have 6 keys and that they match the values 1 to 6? your code should work as long as the keys are there.

  • [quote:3dkoh9xw]i just try it now ...

    when i use on screnn condition with collisions

    it still calculate collisions even when object is outside screen

    and if destroy the object it will calculate 0 collisions

    try an example ...

    What I wrote above doesn't really make sense, so let me try again, using on screen doesn't make much sense. Because if you want to be able to scroll it wont work, and if it aint possible then you don't need a big layout either, so distance check make sense to use and not really "On screen" unless its not a normal layout for some reason.

    The reason yours doesn't work is probably because you use "On collision"?

  • [quote:3fbcni14]yes you get reason

    is on layout or on screen it will still calculate same collisions BUT if we destroy the object it will reduce ...

    No, even if you destroy the object it wont have any effect on the collisions. You will save some memory etc as someone else mentioned.

    You can do the is on screen that would help, sorry missed that part. But then you might as well use a distance check as you can then make it smaller than the screen size.

  • [quote:1cmp8bho]yes

    and if thats like you said better add condition to collisions script

    for example like i said

    if object A (player) is on collisions with object B (ennemy)

    and if object B is on screen

    this will tel to construct engine to calculate colissions only if object B is on screen

    ??? am i logic ?

    I would still say no, I don't see any evidence that it should matter in regards to collision checks. As you can test it pretty easy. Make 2 sprites and put them on the layout.

    In the code you write "On collision object 1 with object 2" that would give you 60 collisions checks, if you move one of the objects out of the layout you get 0 collision checks. So to check if its on layout doesn't matter.

  • [quote:1ubmx79n]Getting rid of objects outside layout will help (they normally are collision checked, and even if not because of collision cells, it still helps a little),

    What do you mean with that they are normally checked if outside layout, its standard that they are excluded if outside layout, or do you mean something else?

  • if we destroy object ... outside layout ... may this will reduce collisions calculations ? no ?

    Objects outside layout are not included in collision detections so it wouldn't change anything in this regard.

  • [quote:svzk0u2n]What is the real difference with overlaping and collision? and how comes overlapping uses less resources? Are they using different algorithms? or only about collision plygones?

    I don't think there are any difference in the code. If you look at this example:

    If you compare the basic "On collision" with "Is overlapping" you get the same amount of collisions. However if you modify the "Is overlapping" and it has to be done exactly like this, with a For each and the distance check as second condition you can reduce the amount of collisions which makes it more effective. You cant do that with the "On collision" it will check all objects on the map constantly.

  • I get about 60 fps on mobile but it reduces slightly when the collision checks happen, i was wondering if creating objects would take up more resources for a mobile device.

    As stated collision checking can be rough, be sure to use "is Overlapping" rather than "On collision" if you don't already it requires less resources.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Its always a good idea to clean up objects that are not needed, so in that regard I would suggest doing that. However if you only have a few objects in your game, I doubt you will notice any improvement.

    How many objects are you talking about? and have you tried to use the debugger to get an estimate of how many resources your game is using?