R0J0hound's Recent Forum Activity

  • I'd imagine the performance would be better after exporting. It's hard to design for this since the texture atlas is done automatically and you're still bound by a maximum texture size.

    To see if your idea would be faster you'd need to make a test either way and measure the performance. This is assuming that's where the bottleneck is at in your game. My machine is weak with html5/javascript so logic is often the bottleneck instead of rendering. Well I have a slow rendering issue as well since my graphics card is in driver limbo, so I'm hit by both sides.

  • Ashley can probably answer more precisely and you can find some more info on C2's renderer on Ashley's blog, but I can give some overview. Basically images are moved to video memory once and when rendering webgl is told which texture to use, the opacity and the quad's four corners' xy and uv coordinates. C2 uses sprite batching to group sprites with the same texture together and reduce the draw calls to lesstexture switching and sending bigger chunks of the quad vertices. Now as to your question I imagine if you had only two instances of one object and each had a different frame then that would be two draw calls. However on export C2 creates texture atlas' of the frames if it can, so then it may take only one call. To be more exact about a draw call, it is only done once per frame in webgl. Everything else is just sending info to webgl to use when the frame is drawn.

  • Look in the pin behavior. At least I think that's the behavior that does it, there are others. The function was called tick2() but now it's called posttick or something like that. The function is usually right after the tick function.

  • You can use Browser.ExecJS("'\x41'") to do any ascii letter from a two digit hex. In this case it's "A".

    It's not needed though since you can use " " and newline. Backspace seems it would be useful but it does nothing in javascript. You'll have to do something link set text to left(text, len(text)-1) instead.

  • Here's something that works.

    https://dl.dropboxusercontent.com/u/5426011/examples21/clearWhite.capx

    To make it work with an imgUrl change the executeJs in event 2 to something like this:

    "this.clearFill('"& Canvas.imageUrl&"'," & int(TextBox.Text) &");"

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It's possible to do with the canvas plugin since as a basic requirement you need to be able to get and set pixels. The issue is the plugin doesn't have a direct way to erase pixels. Currently the only way to erase a pixel is to paste a 1x1 sprite with the destination out blend.

    You'll have to do your own flood fill which is simple enough. Wikipedia has some useful info on how to do one.

    The tolerance can be done with a 3d distance from color to color.

    So a pixel is only flood filled if

    Sqrt((255-r)^2 + (255-g)^2 + (255-b)^2) <= tolerance

    There is a capx that does a simple flood fill with just events. It is rather slowish so it would be better if the whole bit was done with javascript for speed.

    I haven't put much time aside as of late to make examples or tinker with much coding, so I can't help much furthur ATM.

  • One way to get the height of the first line:

    GetToken(ListBox.LineText(0), 1, " ")

    2nd:

    GetToken(ListBox.LineText(1), 1, " ")

    3rd:

    GetToken(ListBox.LineText(2), 1, " ")

    ...

  • You mean like the arcade mario bros or the 2player battle mode of super mario 3?

    One way that come to mind is to add another dummy player sprite that you position at the opposite side of the screen. For example If the player is near the right of the screen the dummy sprite is a screen width left of the player.

  • You could look in the "exporters" folder to look at the source code of the pin behavior. If you want to do it in Construct Classic I think in the examples section there is an example of arrows sticking into an object, which does basically the same thing as the pin behavior.

    Off the top of my head you could do pin like this:

    1 Create two sprites, childSprite and parentSprite.

    2 Give childSprite four instance variables: parent,dist,ang,relAng.

    Parent will store the uid of the parentSprite to be pinned to, use -1 for none.

    Dist and ang are the distance and angle to position from the parent.

    RelAng is the relative angle between the parent and child.

    3 Here's an example of an event to setup a pin.

    On ChildSprite collides with parentSprite

    • --childSprite: set parent to parentSprite.uid
    • --childSprite: set dist to distance(parentSprite.x,parentSprite.y,self.x,self.y)
    • --childSprite: set ang to angle(parentSprite.x,parentSprite.y,self.x,self.y)
    • --childSprite: set relAng to self.angle-parentSprite.angle

    4 Then position the pinned objects with:

    For each childSprite

    Pick parentSprite by uid childSprite.parent

    ---childSprite: set position to parentSprite

    ---childSprite: move self.dist pixels at angle self.ang

    ---childSprite: set angle to parentSprite.angle+self.relAng

    Edit

    The collision response will be interesting, you have choice of either doing the motion yourself or seeing if you can bend the physics behavior to your own devices. Either way you'll want the center of mass. Instead of just finding an average of the positions you need to incorporate mass which is simple enough.

    COMx =(mass1*x1+mass2*x2...)/(count*total_mass)

    COMy =(mass1*y1+mass2*y2...)/(count*total_mass)

    And then you can calculate the force and torque to apply to it with roughly this:

    Linear force =applied force magnitude* dist from com to applied force loc * cos(angle of applied force- angle from applied force to com)

    Angular torque is the same as above except use sin instead of cos.

  • Outside of an effect the paster plugin has a draw quad action that could be used to do a skew of an image. You just need to calculate the positions of each corner. I think there is a capx on the paster topic demonstrating the action.

  • The math as newt wrote works. As you wrote it is incorrect, you added some parenthesis that weren't there.

    Edit:

    Well, since I posted you edited your post or some nonsense like that. So now the formula is correct and the numbers look to be in the range you'd expect. If you want to be more sure of the formula then I recommend reading up on converting polar coordinates to Cartesian coordinates.

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 157 followers

Connect with R0J0hound