Yann's Recent Forum Activity

  • In the console you can read:

    XMLHttpRequest cannot load http://www.mattepainting.be/index.txt. Origin http://mattepainting.be is not allowed by Access-Control-Allow-Origin

    try to put the index.text in the same folder as your "game" maybe (: (and change the url queried accordingly

    The other solution would be to create a .htaccess with the proper things in it to set Access-Control-Allow-Origin properly. But it's not a good thing security-wise.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Don't use AJAX.LastData as a tag (:

    And also, I'm not sure that the On created is triggered if the object already exists in the layout

    Try

    On start of layout:
    [ul]
    	[li]> request "http://mattepainting.be/index.txt" tag "aSimpleString"[/li]
    [/ul]+AJAX On "aSimpleString" completed
    [ul]
    	[li]> Textbox: set text to AJAX.LastData

    Also by renaming index.html to run.html you break a reference in the offline.appcache manifest.

    You should either keep the index.html name or modify it inside the manifest.

  • Functions.Call("Srand",20,90)

    Your function name is just the first parameter of the Call() function of the Function object (:

    If you use this though the return value can be directly assigned to a variable

    -> System: set myVariable to Functions.Call("Srand",20,90)

    The other way to do it is

    -> Function: Call "Srand" (20,90)
    -> System: set myVariable to Function.ReturnValue
  • As far as I'm concerned, I don't like working with too many layout or event sheet.

    I only duplicate event sheet if a part of my code needs to be reused in more than one event sheet (which rarely happens)

    OR

    If I'm making a series and I have a common part and a variable part. This way I can use .bat files to always keep my common part in sync with the series (of course using the save as project for everything)

    I use groups where most people use tonnes of event sheet. To organize code.

    And sometimes, because it's easier, I use activation/deactivation. But I don't like it too much since I'm never quite sure I won't rename a group and then break these actions at some point.

    Anyway the advantage of groups over event sheets to me, is that you can do

    - a rightclick > collapse all to have a better view of all the part of your code and quickly access them.

    - you can be more descriptive with a group (like what it does and then in description I often put a list of the function definede inside that group)

          - it's easier to read than tab names when there's a lot of them

          - it's also easier to do a search on all your events if you only have to search one event sheet. For instance, if I want to see where a function is called (because I want to add or remove an argument), I just type the name of this function in the search bar and I can quickly access all the references.

    Now as far as code goes:

    • I put everything under functions. This way I always know and control when a part of code is executed and I avoid most problematic ordering issues. The only things I don't use functions for are:

          - things that should happen or be evaluated every ticks

          - things under triggers (on click, on key press, etc) though I often call functions from there like "Button: on click -> Function: Call Button.action() with action an instance variable containing the name of the function to call.

    • I use global variables sparringly. For the same reason. If you modify global variables in two different areas of your game, you have to always keep track of when things happen. It's asking for trouble. Also polluting the global scope is a pain (too much thing in combobox menus)
    • Instead of global variables, I use a lot of static local variable. They behave the same but since they are scoped I'm sure they are modified only inside their limited scope.
    • I avoid like plague what is called "magic numbers". A magic number is any number you use in an expression. There are two reasons I avoid them:

          - first, they doesn't mean anything by themselves. What does 1.73 means? Nothing.

          - Second, they may change during your development. For instance if you have a grid based game and at some point you find out that the size of the grid is wrong, you'll have to change all the expression where the width and height are used.

    • I use constants a lot! Mainly to define most magic numbers. This way I can do Global constant number MY_HEIGHT = 1.73. I even do something like TRUE = 1 and FALSE = 0 and I also name array indexes like X_ = 0 and Y_ = 0 (the underscore is here because I often use x and y as temporary local variables)
    • Constants can be global since they can't be changed. But using local constant can be a good idea since you limit global scope pollution.
    • I always write my function in subevents of the "on function" event this way they collapse more nicely, and I add a little comment on top explaining what argument they take and what they return (if it's not obvious). This way I can forget how they are implemented (abstraction).
    • I use only one "on start of layout" event and I put it on top of the event sheet. Rarely in a group.
    • I agree with squiddster, I try to use as less object types as possible. For instance I use only one Button object and I do what I explained above "Button: on click -> Function: Call button.action()

    I talk more about my practices in my C2 Channel by the way. I'll soon start a RPG series where amongst many other things, I'll show you how I handle the problem described by sqiddster:

    "Have your layer setup fleshed out before making the first level of a game with many layouts. It's incredibly boring to mirror layer changes across 50+ levels. (@Ashley this seems something the engine could well improve upon.)"

    Which is something I try to avoid, it's too hard to anticipate all the layer you'll need, you kind of lock your development too early in my opinion.

    I fell into the "mirror layer changes across 50+ levels" trap.... Never again! Yann2013-02-08 05:16:17

  • Hey thanks guys (:

    I made a little erratum video

    There was a little bug creeping in the dark :3

  • The spawn action is an object action, the create object is a system action.

    The consequence of this design, is that if you call the spawn action each picked object will spawn something

    The second difference is that the spawn creates an object at the position of the calling object.

    In short, spawn is equivalent to:

    foreach object -> create object at object.X, object.Y

    As far as retreiving UIDs, you shoudl be able to do it like that:

    -> Create/Spawn object

    -> set variable to object.UID

    For IIDs I don't know exactly when IIDs are assigned and/or reevaluated. But usually, since there shouldn't be any "hole" in the IIDs the one attributed to the newly created object should be equal to object.Count. (ie: if you have 3 objects they probably have the IID 0,1,2 so the next one will be 3)

    But you shouldn't rely too much on IIDs, I don't exactly know when they are assigned or recalculated, and with so much imprecision you really should use your own indexing (with your own instance variable), and C2 could change their way of doing things. IID are good for temporary uses or when the state of instances don't change.

    When there's creation/destruction involved, you're better off handling things yourself or using UIDs.

  • Thanks (:

  • TELLES0808 You're welcome (:

    Two new series of video on my polygon plugin

    • Polygon Plugin:
      1. Polygon Splitting:

        Enjoy :D

        I decided to stop posting the twitch links, since the videos are unedited.

        But if you are curious to see the rough product of my screencasts, you can still see them on twitch (:

        And subscribe on twitch if you want to be warned when I'm broadcasting. You could ask some live questions (:

      2. Link to .capx file (required!):

        accessingLocalConstantVariables.capx

        Steps to reproduce:

        1. create a group

        2. create a local constant inside the aforementioned group

        3. create an event that reads this variable (ex: on start of layout -> Text: set text to LOCAL_CONSTANT)

        4. run the preview

        Observed result:

        If you open the console, you should see the following line:

        "Check: local var stack holds undefined value"

        Expected result:

        Nothing. But it's a problem when you have such access constantly in different places since it will flood the console.

        Browsers affected:

        Chrome: yes

        Firefox: unchecked

        Internet Explorer: unchecked

        Operating system & service pack:

        Windows server 2008 r2 SP1

        Construct 2 version:

        r117

            Yann2013-02-01 19:00:54

      3. Oh, indeed, my bad, you can discard all my replies I didn't see you were already doing what I discribed (:

        So for now I don't know why you have collision bugs, one of my hypothesis at some point was imprecision in the collision polygon or in the shape's position. But it seems you were pretty cautious here.

        So, dunno (:

      4. well it's common practice to use an invisible rectangle as your true character and make the graphics/animation of your character follows it.

        What I discribed earlier is just the step to follow to have the least amount of thing to change in your event.

        Mainly transforming the original player sprite into the aforementionned rectangle (so you still control it) but before, you clone it to create a new object but with your animations in it, so you just have to re write the events concerning animation to target this new clone (clone isn't an instance by the way it's a whole new object)

      5. Yeah new vid \o/

        Here I give an example as to how to use the timer system I created in the last video and at the same time a possible solution to a common issue with sound on some devices.

        Timing Audio:

        - twitch

      Yann's avatar

      Yann

      Member since 31 Dec, 2010

      Twitter
      Yann has 5 followers

      Connect with Yann