kinnon's Forum Posts

  • I write little tutorials for my students. currently I'll create a small demo cp3 file and the guide is usually a one or two page Word file, or an html page in a VLE.

    I've been working with .md files and it occurred to me how handy it would be to write a short guide in markdown and put it in my Construct project Files folder as something students could have open in a project tab.

    Is it possible to view md files while a construct project is open?

    Alternatively, could I save an html file into files and allow it to open for reading instead of editing? Possibly opening it in read view for existing files, and have an edit mode option or something?

    I suspect these are more feature requests than something I can do now?

    Regards,

    Allan.

    Tagged:

  • Ok, back at it. I would like to use TensorFlow Body-Pix to segment the webcam image.

    I'm picking at a range of tutorials, including this: blog.tensorflow.org/2019/11/updated-bodypix-2.html

    Within my main.js script before anything else happens I tried the following two lines, and both failed with the same result:

    //import * as TensorFlow from 'https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@0.13.3';
    import * as TensorFlow from './tf.js'; // local copy in script folder
    /*
    Uncaught TypeError: Cannot read properties of undefined (reading 'tf')
     at tf.js:2:149
     at tf.js:2:157
    */
    

    I have a horrible feeling that although this looks ESM complaint it's a compatibility issue and modifying TensorFlow or body-pix is not something I'm ready to commit time to. I would be delighted if it was something I was doing wrong.

    Here's my project file: https://www.dropbox.com/s/1flvynxgtjsz0jk/webcamTest_20201011.c3p?dl=0

    Any help getting off the ground would be appreciated and I'll share my project if I ever get it working.

    Regards,

    Al

  • Quick FYI for those interested. Uninstalling Cheese fixed my ps2 eyetoy webcam issue.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • OK, progress so far. Looking into the use of face-api.js to do this, with a chroma filter applied to green screen the background. my plan is to extract the face area, then make all the green bits transparent.

    Work in progress, but getting there. I've hit a bit of an issue. This needs to run from a Linux machine.

    I have Linux Mint 21 Xfce installed on an old PC, with a PS2 EyeToy set up as webcam. The webcam works well with other applications such as Cheese, but when I try to access it from my construct 3 game, I get nothing.

    Permissions pops up, and I click the button to approve access, but nothing shows in the user media preview, and no pic is captured when I press a button.

    This works on Windows 10/11 but on Linux I get no picture back with Chromium or Firefox.

    Any advice welcome.

    Event sheet is as follows:

    Regards,

    Al

  • As a novelty, I would like to extract a face from a webcam, put it into a sprite, and pin it to the player's sprite as its head.

    I have a User media object and sprite object, and a keyboard object.

    At first I thought maybe I could use a green screen, then add an effect to replace the green colour from the image with a transparent alpha colour, but this is not working so well.

    Then I figured, how about if I put an oval over the usermedia cam stream, and ask the player to position their head inside the oval? I could then use only the image data inside the oval in my sprite image. I have no idea how to tackle this so looking for any suggestions.

    This is for students and high school kids studying at our college campus to play with and possibly implement in their game projects. Some of my previous students had a hoot using cropped side-on headshots of themselves on their platform characters. It would be so cool to integrate the capture process in their games.

    All the best,

    Al

  • Thanks for the info fedeca, much appreciated.

    It does look somewhat complex; I shall digest and share my results once I've got somewhere.

    Regards,

    Al

  • Hello,

    I hope my explanation makes sense...

    I'm trying to calculate the x and z position of the 3d camera in order to orbit round the middle of my layout, always facing the center of the layout at a z position of 0.

    ranges are

    x: -100 to LayoutWidth +100

    z: -100 to 100

    If we pretend the layout+100 is 2000 wide for the sake of simplicity, the following should be true for each quarter of the orbit:

    x z desc

    ---------------------

    0 0 Cam pos is far left and layout middle (edge on looking right)

    1000 100 Cam pos is front and center of the layout

    2000 0 Cam pos is far right (edge on looking left)

    -1000 -100 Cam post is rear center looking in from the back

    At the moment I've been incrementing and decrementing values to try and do this, and the result is more like ping pong than an orbit (example project https://www.dropbox.com/s/64dgaklczg96eu3/3dOrbit.c3p?dl=0).

    I'm sure theres a nice calculation that can make this work nicely and produce a smooth constant orbit, but so far I haven't worked it out; my math muscles are in need of some exercise.

    I've also looked at orbit and rotation behaviours to try and solve this, but they only rotate round the xy axis and not the z; which is important to me.

    Any help would be appreciated.

    Tagged:

  • Thanks Ashley, great article. Not sure it applies here.

    the student is using a small number of sprites with movement managed with behaviours only.

    The ball is rotated 180 degrees when spawned if the player is facing left, then managed by the behaviour.

    Objects are:

    name type behaviours instance vars
    player sprite platform, scrollto health
    ball sprite bullet (with bounce)
    platform sprite solid
    lava sprite
    thealth text
    bg sprite
    keyboard

    most sprites are 16x16 pixel colour filled squares.

    ball is 8x8 pixels, still with square collision box.

    bg has a large 1920x1200 image and in a background layer with 50% parallax.

    Text copy of the event sheet is as follows:

    [System Rules]

    ----+ System: Every tick

    -----> tHealth: Set text to "Health: " & player.health

    [Player Rules]

    ----+ player: Is overlapping lava

    --------+ System: Every 1.0 seconds

    ---------> player: Subtract 1 from health

    ----+ player: health ≤ 0

    -----> System: Restart layout

    ----+ Keyboard: On ← pressed

    -----> player: Set Mirrored

    ----+ Keyboard: On → pressed

    -----> player: Set Not mirrored

    [Ball Rules]

    ----+ ball: On collision with player

    -----> ball: Destroy

    ----+ Keyboard: On Space pressed

    --------+ System: ball.Count=0

    ---------> player: Spawn ball on layer "main" (image point 0) (create hierarchy: False)

    ------------+ player: Is mirrored

    -------------> ball: Set Bullet angle of motion to -180 degrees

  • Sorry, further information on this. the issue was where the student had a sprite spawn a single 8x8 pixel bouncing ball bullet sprite, the bullet sprite was not visible on screen at 240hz.

  • Hello,

    I have a student starting games development with me, beginning with exercises using C3. Working remotely from home, so using his own setup.

    The student was having no end of issues spawning bullet objects, and the project runs perfectly for me.

    Turns out his refresh rate was the issue. 240hz !! Dialling back to 60 fixed it.

    Monitor: Dell AW2518HF

    GPU: Radeon Vega 64

    Apparently frame rate was 240fps!

    Changing the framerate to 60 fixed the issue.

    I'm no hardware expert but figured I should share.

    Regards,

    kinnon

  • Ah, thanks dop2000. That sounds perfect, I'll try that. Didnt even realise C3 had a canvas object. Thats just opened up a whole world of possibilities!

  • Hi, I've been searching for this but haven't found an answer yet.

    Currently, if I create a demo with explosions or damage impact, I spawn small groups of tiny sprites which stick to damaged player, npc, or destructible sprite objects; as scorch marks or surface damage. These are pinned to the surface of a sprite until it is destroyed. These tend to be 4x4 pixel black or grey dots, so its a lot of resource having each one as a pinned sprite.

    A more effective way to do this would be to draw directly into the frames of the current sprite instance.

    E.g.

    bomb - on collision with - building ... thisBuilding.animations.frames(0).drawRect(x1, y1, x2, y2, colour_code)

    Is this possible in construct 3?

    Could I read a pixel colour value and use that to darken and increase transparency?

    Many thanks,

    Kinnon

  • Apologies for the late response, I've been a bit preoccupied over the last few months.

    Thanks for the reply Dop2000. Good ideas here. I'll have a go and see what works for me.

  • Hello,

    I the attached example, I have a slider bar with a range of 0 to 3000.

    I have an object called spawner. If spawner is not overlapping an object called wall, it spawns one. Each wall is a bullet travelling on the screen at the speed set by my slider, so when I move the slider, all wall speeds are changed to match it. The wall object is set as semi-transparant so the overlaps can be seen more clearly.

    I want the walls to spawn so there are no gaps, no matter what I set the speed to. small overlaps are not an issue.

    The problem is, as I increase the speed, the spawner seems to not be able to keep up, and I have increasing gaps between walls.

    I have seen similar questions asked, however I've not seen a solution that works with this yet. Any help would be appreciated.

    The event sheet is as follows:

    Example project: https://1drv.ms/u/s!Avy7YzN_HRXtgwY0jAiJKS_XOBbB?e=QhVz4D

    Regards,

    Al

  • Hi, That work well. Very elegent logic.