nimos100's Forum Posts

  • My best guess from what i can see in the screenshot is that its caused by Timer <= to 0, and would expect that your timer either gets stuck on 0 or lower, and therefore this keeps being true. And it will keep switching between your states. (60 times a sec) which probably explain why you say it goes crazy

  • I dont think adding a layout for each type of question is good, as it might lead to some confusion.

    Since you already know the rules of your game before hand, for instant. If its a "Yes", "No" question there will 2 options, if its a multiple choice question there might be 4 options, and if its words there might be 5 options.

    In that case I think I would go for a dynamic generated question sheet or what to call it. Meaning that you use the same elements for all the questions and answers and then just replace the texts with what is needed.

    And actually it might be easier to simply store each question with its answers as a small sprite object of something like 8x8 pixel.

    So each sprite would have the following attributes.

    Question = "The question it self": "What is 2 +2 ?"

    Answer 1 to 5 = "If there should be max 5 answers"

    Correct_answer = "Hold the number of the correct answer"

    What you can then do when you have created all your questions etc. is to simply tell C2 to pick a random Object of question, and then you read that question objects attributes into your question sheet, that the player sees on the screen.

    Each of the buttons on the question sheet should have a variable going from 1 to 5 matching the answer. So Answer 1 from a question goes into button 1, answer 2 to button 2 etc. You can just do that before hand.

    And then you check if what the player pressed matches the variable in the "Correct_answer" of the question.

    That way whenever you feel like making a new question you simply copy/paste a question object and changes the settings to match what you like, and the code will automatically include it into the game.

  • Wrote a small example here, that you might find useful.

    https://www.scirra.com/forum/viewtopic.php?t=97305&p=743528#p743528

  • While nimos100 might have posted good advice, I don't believe any of it will have any measurable effect on performance.

    Ohh...my post have nothing to do with performance, its was solely meant for organization of projects. Think I missed that part from the OP

  • [quote:2csun37y] I Know than folders and subfolders haven´t impact in performance, but what happen with sheets?... example now I am working in a game will have 30 scenes/levels. I am working with: Functions sheet, Variables sheet, Controls sheet, Bug sheet, quick reference function sheet and a lot of more...plus 30 SCENES sheet!!!! thats a lot of sheets... or I can use only one sheet for all scenes???

    I know Guizmus said that if you works fine you include only what you need where you need (CPU friendly) but I am a n00b already... so I don't know if I must works with decens of sheets lol

    Organizing sheets sounds really easy, but it can actual cause some problems, since its not uncommon that events/functions involved several things, so where should they go, or should you make a new sheet etc.

    The way I would do it, is to think about key elements or functionalities of your game. And turn these into event sheets.

    I wouldn't add a event sheet for every scene/level in a game, unless there are significant changes between them. Like level 1 is a platform game, and level 2 is a top-down shooter etc. Otherwise you might actually make several functions that do the same.

    Instead I would do something like this, it does of course depend on the game you are making.

    1. Game menu

    Will handle everything that have to do with the main menu of the game. Maybe not all the functionalities, but the initial settings. Like making sure that variable that should be reset are so, that rogue objects gets removed. Access to Load game so the player might only be able to press this button if there actually is a save game to load. Open game settings and exit the game.

    2. Game

    Will handle stuff that have to do with the general things that have to do when the player have started the game. This can be pause game, buttons that are on the game area. etc.

    3. Game functions

    Could add Hud updating here.

    4. Player controls

    Will take care of player controls.

    5. Player functions

    This can be functions such as reducing player health, player death.

    6. Enemy AI

    Will handle enemy movement.

    7. Enemy functions

    Same as player functions, except that its for enemies.

    8. Sound

    Handles sounds.

    9. Money / Score

    If you use a advanced system, that would require converting money etc. It can be useful.

    10. Map generator

    Will handle generating maps.

    11. Map functions

    If you need to manipulate the map, like destroying something etc.

    So instead of using 30 sheets for 30 levels, you will make use of several different sheets included into the game sheet. Since all 30 levels use some kind of the same things, like enemies, player etc. These are included, so your actual game area might have 8-9 sheets included.

    That's what Guizmus meant, since there are not reason to include the game menu into the actually game area, if the player shouldn't be able to start a new game from here or include it into the enemy sheet, as it have nothing to do with enemies.

    But yeah there will be a lot of sheets, but it doesn't really matter, if they are organized so you can quickly find what you need, it will be a lot better, that messy sheets, with no comments, no groups etc. Where you will loose overview at some point

  • There are several ways of dealing with this.

    First is that you can add a distance check, so only enemies that are within a certain range will attack.

    You can do that by adding a for each and use Distance(X1,Y1,X2,Y2) and check the distance between the enemy and the player.

    Another way could be to add a reload variable to your enemies, and whenever that is 0 it can shoot. But no matter what you need to add a For each, as of now you select all Enemies that meets these conditions. And since both enemies have line of sight to the player, and are selected with the "Is LOS = true" that will again trigger both.

    Btw you don't need that variable The EnemyShooter -> Has LineOfSight to player already does that. So you could simply add that one instead of the variable.

  • Not sure if it will solve you problem, but it seems weird that the Collision X > 1301 is below Jack Pick nearest ..... As I assume you want to pick the nearest jack to the collisionFamily that are between these values?

  • No problem

  • I downloaded your capx. And have modified it. Just so you can see how to do it.

    Personally I would consider changing the way you select spells, so you could simply left click to equip it in Q and right click to use W. But anyway, I have added comments to it, so you can see what each thing does.

    However here are some further explanation.

    1. I made a family that hold your spells, this is simply so you don't have to repeat the code as much. And to difference between the spells, I have just added a variable to the family called spell_nr. that goes from 1 to 3.

    2. I have added 3 imagepoints to the spell bar, so each spell can be matched to a imagepoint location when they are swapped. Again this is simply to reduce the amount of code needed.

    3. To the two Q and W buttons I have added a variable to hold the nr of the spell that is currently equipped. This is when it is replaced, I can return it to the spell bar, before placing the new one.

    4. The Q W where you select which spell to equip, also have a variable called Selected_spell, which hold the Spell_nr that was chosen. This is so it knows which spell it should equip.

    https://dl.dropboxusercontent.com/u/109921357/Equippind_and_Disequipping_Test.capx

  • I haven't looked at your capx, so depending on how you made it. You can for each hotkey store the spell_UID, spell name or whatever makes them unique. And simply overwrite this value, from what I understand you want it to swap, but actually you don't need to swap, but just overwrite.

    So if you have:

    Hotkey_Q = Spell_1

    Hotkey_W = Spell_2

    And want to change Hotkey_Q, it doesn't really matter what happens to the spell that is already there, so you simply.

    Set Hotkey_Q = Spell_2

    And Spell_1 automatically gets "Unequipped".

    So if you have already made it so you can equip a spell it should work fine if you overwrite them.

    If you want to make sure that the player cant equip Spell_2 two times, you can check in Hotkey_W if Hotkey_Q not equal "Spell name" then equip spell.

    And reversed for Hotkey_Q.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • Here are some advise that might be useful.

    1. Clean up

    Objects that you don't need to be there from the start, by this I mean sprite objects that would be "Units", "Bullets" etc. you should destroy at the beginning of the game. This is simply to make sure that you don't have rogue objects in your program.

    2. Precise functions

    Make as small and precise functions as possible. Even though some of these functions might seem to simple for it to make much sense.

    And example of why this is a good idea. Imagine you have a "Car" and in you code you might change the speed, so you simply as you make the game, set the speed to what ever you think would be good. This would be fine until the moment you decide that it could be fun to add, if the speed gets above a certain amount that the car should start loose control. If you add it in your code you would have to change/test for it everywhere you might change speed, if you have a function you can simply add it here and update it for the whole program.

    3. Global constants

    This can be very useful for reducing spelling errors, and to quickly change things in your game. Imagine as the above example, that you have several car objects which are categorized by a type, "Cheap car", "Normal car" and "Expensive car"

    If you in your code manually add checks if ( Car.type = "Cheap car" ) and then do something, at some point you might figure out that this weren't that good, and it should instead have been something else, then instead of having to go through you whole code, you can just update 3 global variables.

    4. Use several event sheets

    Don't be afraid of using event sheets even though you might not add a lot to them. It will really help you maintain an overview of your game.

    5. Split events and functions

    Unless you are 100% sure that an event sheet should only be used one place, its always a good idea to split events and functions, even though they work on the same object. So an event sheet called "Car events" and "Car functions" would be a good idea. You can always move functions later on, but think it good practice to just get used to splitting them.

    6. Requirements and returns

    When making functions I find it very useful to add comments above them with requirements, and potential return values. This will make it very easy later on as you move along and might forget what a function actual does when you return to it.

    An example could be like this:

    7. Bug sheet

    Make an empty event sheet, that you just use for comments. You don't include it in your program. But the purpose is as you test your game and might be testing something, suddenly notice that something else is not working as intended. Then instead of fixing it straight away, you just in you "Bug event sheet" add a comment explaining what you noticed. And if possible the cause for it. Then you can always fix it later and you wont forget about it.

    8. Quick reference function sheet.

    This can be a bit time consuming but very useful. The idea is again to add an event sheet that you don't include in your program. But you simply add function calls to it, with the required amount of parameters.

    This can speed things up quite a bit as you can just copy/paste function calls from this sheet to wherever you need them, and just update the parameters, and you don't have to remember the name or how you spelled the function name etc.

    Other than that I think the other advise are good as well.

  • First of all sorry for the bad topic name not sure what to call it

    But was thinking of another feature that could be useful, as most are aware of when using lots of function, there might be calls to these all over the place.

    So a feature that could be very useful I think would be if you could right click or shift+left click a function call in your code, and jump to that function. And maybe make it so you could jump back again. Would be very useful, for me at least, I tend to expand functions over time but forget where I put them, sometimes, so it would make it a quick way to jump there. Think that would be a really nice feature.

  • I don't think there exist such place, at least not what I know of.

    But I would say that if you have done all the tutorials that comes with C2 you should have a fairly good understanding of how to do things.

    When I started I just did the first one tutorial, to just get a hang of how to navigate the program, and the rest was pretty much trial and a lot of error, and a good community always willing to help, even with very simple questions. Think that's a big help for anyone new, that they don't feel stupid for asking such questions.

    So if I were you, then I would just choose something that I thought could be fun trying to make, something very simple, and then see if there are a tutorial that uses something that might be useful for that, and then just try to make as much of the game as possible, or start a new project when you notice that you screwed something up big time. And then make use of what you just learned, and maybe add something new that you think could be fun. Then you just keep doing that until some point where you have a very good understanding of how to do the different things.

  • So I'm starting to understand arrays a bit more but still feel like a complete noob, I tried setting some text every tick to "TileProperties.At(Mouse.X,Mouse.Y)" but I am assuming that it's the wrong way as it stays at a constant "0" I'm pretty much just going by trial and error at this point xD

    Yeah that will most likely give you a 0

    The reason for this is probably because there are no data stored at the given position.

    As you move the mouse around, you constantly update where in the array you are reading data from. So if your layout is 1000x1000 pixels. And you move the mouse around you will look up data in the array based on pixels rather than tiles. This is because each tile in the tilemap is not 1x1 pixel big, but might be 32x32 or whatever you have chosen.

    If we assume that each tile is 32x32, then the array at position (0,0) would actually be all pixels from 0-31, 0-31.

    So what you have to do in order to get "TileProperties.At(Mouse.X,Mouse.Y)" to work, is to convert the mouse-position into a tile position. which is fairly easy, using the tilemap function PositionToTile(X,Y).

    So your function should look like this:

    TileProperties.At(Tilemap.PositionToTile(Mouse.X), Tilemap.PositionToTile(Mouse.Y))