Yann's Forum Posts

  • Hum I was wondering guys. Maybe a 2 hours non stop video is really too much to follow through and splitting the video into chunks of 15 minutes like the first one might help people to follow small sessions at a time. What do you think?

    The splitting of the first video was a n00b move on my part. When I uploaded it from twitch I got a warning that the upload might fail if my account didn't accept big videos, that's why I choosed to split them up. But it turned out, my account was ok with big videos.

    On another topic Tobye it's funny, what you are doing int the ilsplayer looks to me that you are kindof mimicking the behavior of a dictionary object (aka hashtable).

    In short you are inserting (Key,value) pairs like that

    inLevel(someIndex,0) = "X"
    inLevel(someIndex,1) = valueForX
    inLevel(someIndex,0) = "Y"
    inLevel(someIndex,1) = valueForY
    ...

    And since you use .indexOf, I guess you are assuming the 'X' and 'Y' keys will be unique in the array.

    So it would be the same as doing:

    dictionary: add key "X" with value valueForX
    dictionary: add key "Y" with value valueForY
  • Tobye

    Alright

    Do you have an example of data you want to store?

    Like, do you have strength/dexterity/speed/hp/mp and position on the map, or, I dunno, or do you have more than that?

    Gimme some more spec so I can narrow down the problem (:

    Tell me what you think about the last vid on array if you have the courage to watch it :D (2h30)

    Maybe you can find the beginning of an answer inside.

  • Whiteclaws

    Lucky you, I don't :D

  • Alright new vid on arrays. Trying to take a new approach by remaking the system to understand and hopefully help you to understand how they work.

    A bit long and complex but hopefully you'll get some insight and some french words (:

    Mimicking Arrays:

    Subscribe to Construct videos now

    - twitch

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • WOW success *_*

    Thanks guys for spamming my mail with your youtube subscriptions (:

    Tobye

    Using Webstorage ?

  • Hey there, I'm starting a channel on twitch mirrored on youtube.

    http://www.twitch.tv/frenchyann

    http://www.youtube.com/channel/UCkBYP-bYZSd8Uf47hPbMx1w

    The goals of this channel is to share some workflow/process/insight/bad jokes on how I would solve a given problem with C2 and also to show some ideas or concepts.

    This is by no mean a "tutorial" channel. Unless otherwise specified, the videos I'll post won't be tutorials. They will be mostly unprepared and unscheduled C2 related tests and ramblings, and of course they will feature dumb mistakes and blunders.

    And they probably won't be for total C2 n00bs.

    However, since I'll be using twitch, you'll be able to join me live and ask questions (you'd better follow me on twitch if you want to catch the broadcast ;p). I probably won't answer all of them, and I'll try to make each session not too long.

    Broadcasts sessions will probably be totally irregular :D (maybe I'll make 3 sessions and then nothing for 2 months). It's mostly a "when I feel like it" kind of rule.

    The first video (split into 6 on youtube) is my answer on a simple problem: "UI selection marquee tool".

    Since the 9-patch appeared in the last C2 release I thought it would be a good opportunity to show it off.

    Feel free to comment here, on twitch or on youtube (but if everybody comments here it's easier to follow)

    And also, you can propose some subject for futur videos.

    I probably won't cover too broad subjects, like "how to make a game hm?", or subjects that already have tonnes of tutorials, like how to make a break out or a platformer...

    Cheers o/

    Video list:

  • Yeah in theory, but I have yet to see a concrete application of "dynamic collision" you can't achieve with a few sprites.

  • Ethan

    yeah I dunno how hard it would be, and to me it would make more sense to be a behavior on top of this plugin than a feature inside the plugin.

    And also remember that drawing polygons is expensive. By looking at the "you shouldn't do that" 3D demo where there's like 30 polygons it's already quite slow (:.

    Jasper

    Heheheheheh asking for new features are you? :D

    I was thinking about that. I left that aside since I didn't need it and I wanted to make it work nicely without worrying about textures (tiling/not tiling/... etc).

    But we'll see if I can do something about it. I'm starting to get the hang of C2's SDK.

    Don't expect it too soon though, but if you see that in one month I still didn't try you are allowed to ask again :D

  • ludei thanks for the info (:

    And yeah as far as drawing goes, I use the canvas context fill/stroke javascript functions and in webgl mode I copy the texture to the webgl context.

  • Another way to see it, it that, if you have to sort all your data, you'll have to manually swap each value (movement, rate of fire, etc)

    I would use two arrays:

    one with the data

    one for sorting.

    An also, if you want so use push, you can serialize your data in one string

    here's how I would do it:

    scoreData.capx

    just input data like that:

    100 0.5 20.4

    (being movementSpeed, rateOfFire, stayedAliveFor)

  • I made a slight little change on the plugin.

    The clear action was clearing the vertex list and its canvas but the texture wasn't updated.

    Now it works as expected (:

  • rexrainbow

    I have no idea, I don't have anything to test that, if you have time to try I'd be intersted to know the answer (although I don't know if I would be able to do anything about it if it doesn't work)

    What I can tell you is that it runs with webgl on and off (:

  • I just tested with physics, and although I get a scary error message on preview, it seems to work super fine (some one said Crayon Physics Deluxe?)

    https://dl.dropbox.com/u/23551572/C2-Games/Physics%20Test/index.html

    Maybe Ashley can shed some lights on it:

    is it a bad idea to used physics with my plugin? or can the error message be disabled somehow?

  • Hi! guys

    Last-Edit 2013-04-23:

    bug fix: ctx.drawImage() didn't like textures of size (0,0)

    Edit 2013-03-03:

    bug fix: wrong bounding box expressions.

    I made a plugin to draw polygons (:

    Properties:

    • Collision: Enabled|Disabled
    • Debug Mode: Enabled|Disabled

    Condition:

    • Is overlapping another object

    Same as Sprite is overlapping

    • Is overlapping at offset

    Same as Sprite is overlapping at offset

    • Collisions enabled

    Same as Sprite collision enabled (return true if collision is enabled)

    • On Drawn

    Trigger when the Draw action is executed

    • Compare area

    Compare the area of the drawn polygon

    Actions

    • Add Vertex(x,y,local or world-space)

    add a vertex to the vertex list

    • Remove Vertex(index)

    remove a vertex from the vertex list

    • Insert Vertex(index,x,y,local or world-space)

    insert a vertex in the vertex list

    • Move Vertex(index,x,y,local or world-space)

    move a vertex of the vertex list

    • SetOrigin(x,y,local or world-space)

    change the origin of the polygon

    • Log Vertex List

    print vertex list in the console log

    • Draw Polygon(fillColor,lineWidth,lineColor)

    draw the polygon using the vertex list, filling the shape with fillColor and stroking the outline with a line of thickness lineWidth and color lineColor

    • Clear Polygon

    clear the vertex list and erase the polygon

    • Load(JSON)

    load a vertex list in JSON format

    • Download

    open a window with a download link of a JSON file containing the a vertex list

    Expression

    • Area: area in px of the shape. gives a wrong results for invalid polygons (when edges cross each other)
    • asJSON: return the vertex list as a JSON string (to use in the load action)
    • OriginalWidth: width of the original polygon texture
    • OriginalHeight: height of the original polygon texture
    • LocalVertexX(index): the original values entered in Add Vertex (local-space)
    • LocalVertexY(index): the original values entered in Add Vertex (local-space)
    • VertexX(index): X position of the vertex (by index) in world space
    • VertexY(index): Y position of the vertex (by index) in world space
    • VertexCount: total number of vertices in the vertex list (usefull to loop through them)
    • Left: X position of left of unrotated bounding box
    • Right: X position of right of unrotated bounding box
    • Top: Y position of top of unrotated bounding box
    • Bottom: Y position of bottom of unrotated bounding box
    • CenterX: X position of center of unrotated bounding box
    • CenterY: Y position of center of unrotated bounding box
    • BarycenterX: X position of barycenter (average of vertices position)
    • BarycenterY: Y position of barycenter (average of vertices position)

    How does it work?

    A polygon is defined by an ordered list of vertices.

    To create this list you use the action Add Vertex.

    The order in which you add vertices is important. The plugin will draw the polygon starting from the first vertex you added until the last one and close the shape back to the first.

    Another thing to keep in mind, when you Add vertices, you add them relatively to the position/orientation/scale of the object (local space) or directly in the world position (world-space)

    So if you want to make a square around the origin of the object you will have something like that:

    global number sideLength = 100
    Polygon: Add vertex -sideLength/2, -sideLength/2 (local-space)
    Polygon: Add vertex sideLength/2, -sideLength/2 (local-space)
    Polygon: Add vertex sideLength/2, sideLength/2 (local-space)
    Polygon: Add vertex -sideLength/2, sideLength/2 (local-space)

    But if you do only that, nothing will happen. Once you've built your vertex list, you have to tell C2 to draw the polygon (it's not done after each Add for obvious reasons (:)

    To draw the polygon, it looks like that:

    Polygon: draw with outline (1.0 px, "rgb(255,0,0)") and fill with ("hsl(180,50%,50%)")

    (you have to specify color with a string (in "") and you can use either rgb(r,g,b), hsl(hue,saturation,lightness) or "#rrggbb" or special recognized values like "black" "red" "green" etc)

    You can move, or remove vertices via their indexes (0-based)

    If the index you specify is negative or greater than the index of the current last vertex, it won't do anything and will write a warning message in the javascript consol (only in debug mode and preview).

    You can insert a vertex inside the list by giving an index.

    If the index you specify is negative or greater than the index of the current last vertex, it will be respectively clamped to 0 or [index of the last vertex] + 1

    Clear polygon will do two things at the same time:

    empty the vertex list and delete the current polygon texture.

    JSON support

    I basically copied the piece of code from the Array plugin. So you can load and save a vertex list in JSON format.

    It can be usefull if you want to copy a polygon shape or save some shape for later uses (polygon editor?)

    Scaling

    When you use the draw polygon action, you basically create a texture. This texture can then be scaled using width/height, and rotated using angle.

    But remember that since it became a texture, you will see stretching artefacts.

    Another thing to be aware of, if you stretch your polygon, you basically modify the relation between originalWidth (which is the distance between the left most and the right most vertex in local space) and current Width of the object.

    The draw polygon action will keep this relation.

    If your width is twice your originalWidth, and you modify your vertex list and draw, the ratio will be kept.

    Local-Space vs World-Space

    Add, Insersion and move can be either done in local space or world space.

    Local-space means relative to the space of the polygon object. So if you add vertices and then change the angle of the object, you'll have the same result the other way around.

    Via expression, you have access to the local coordinate (LocalVertexX,LocalVertexY) or the world-space coordinate, their real position in the world (VertexX,VertexY)

    Area

    The value you get from the Area expression or evaluated with the Compare area condition will be right for convex and concave polygon but wrong for invalid polygons (when two edge cross each other).

    Origin

    You can set the Origin of the polygon wherever you want to, even after your vertex list is built.

    The vertex list will be recalculated accordingly, and the position will be changed so the origin is moved but nothing is changed visually.

    It may be usefull to set a new rotating point or anything you want to do in runtime.

    You can test it in the demo.capx in the zip or Creation/Edition demo below.

    Debug

    To help you during development, you can enable the debug mode property.

    When this property is enabled, and ONLY in preview (this way if you forget to disable it for export it won't be a problem) each action will throw a message in the javascript consol.

    This way you can see what vertex are added, inserted or removed, when polygon are drawn and when JSON's are loaded

    But sometimes you don't need that much, or you would prefer triggering debug information yourself via event.

    For that, you have the log vertex list action. It will write the list of vertices in the console (only in preview)

    Demo

    You can test everything about scaling, rotating, vertex creation here:

    Creation/Edition

    Just to fool around

    Creating random graphs

    One possible application of it:

    Split poly

    <show off>

    One crazy really unusable and "you shouldn't do that" application:

    3D rendering

    </show off>

    Download

    Here is the plugin with the capx of the demo in it.

    (I didn't provide the 3D one because I don't want to encourage anyone to use that method (:)

    polygon.zip

    I made some video to show you how I to use it

    Polygon Plugin:RamblingActionsExpressionsPolygon Splitting:Starting ShapeCutting NodesNode SelectionSplit FunctionLine EquationGroupingChildren CreationPolygon SelectionHelper FunctionsFeedbacksNode FilteringLittle BugFinal Rambling

    Do remember that drawing a polygon is an expensive computation, avoid as much as possible to do that every tick.

    I hope you like it and don't hesitate to report bug and tell me how you used it (:Yann2013-04-23 00:21:22