GeorgeZaharia's Recent Forum Activity

  • So we all been looking around internet lately and heard and read about ChatGPT right? but did you knew? that you can ask him to give you "construct code" snippets ?

    i did a test today. it knows everything about construct plugins, behaviors etc basically the entire manual and what construct is made off... and that made me think... can chatGPT generate construct usable event sheet code snippets? and to my surprise... it did.. somewhat not what i expected but definetly blew my mind... so my test consisted of this

    and then ChatGPT answered with this

    ======================================

    Sure! Here's an example of how you can create a cue stick that follows the cue ball in a circular pattern around the cue ball using Construct 2:

    Create two sprite objects in your Construct 2 project: "CueBall" and "CueStick". Set the origin point of the "CueStick" sprite to the center of the sprite to make rotation easier.

    Place the "CueBall" sprite on the game layout where you want the cue ball to be positioned.

    In the event sheet associated with the "CueStick" sprite, add the following events:

    Event 1: Every tick

    Add an action to set the position of the "CueStick" sprite to the position of the "CueBall" sprite.

    Event 2: Every tick

    Add an action to set the angle of the "CueStick" sprite to the angle between the "CueBall" sprite and the "CueStick" sprite.

    Use the following expression to calculate the angle:

    angle(cueBall.X, cueBall.Y, cueStick.X, cueStick.Y)

    Event 3: Every tick

    Add an action to set the position of the "CueStick" sprite relative to the "CueBall" sprite in a circular pattern.

    Use the following expressions to calculate the position:

    scss

    Copy code

    Note: "radius" is the distance between the cue ball and the cue stick, and "angle" is the current angle between the cue ball and the cue stick.

    Adjust the value of "radius" to control how far the cue stick should be from the cue ball, and test the project. The "CueStick" sprite should now follow the cue ball in a circular pattern around the cue ball.

    Note: The above example assumes that the "angle" variable is in degrees. If you prefer to work with radians, you can use the "radians(angle)" expression instead of "degreesToRadians(angle)" in the calculations.

    Please note that Construct 2 uses a visual programming system, so you can implement the above logic using the available actions, conditions, and expressions in the event sheet, without writing actual code.

    ===============

    initially i tought it will give me some behavior pin to etc type of thing... but this is more usefull than i tought... i wonder now can it do more complex algo and js compatible things? i mean... logically should right?

    what you guys think about this?

    i posted in Open discussion cause i don't know if this is a tool or general discussion or what... but i find it pretty neat that, when we having problems in Construct programming we can ask the community for help but that takes time a lot of it usually... this method would basically solve "small" requests in a instant. or atleast put us on the right path.

    ================

    after i added the mouse plugin so i use the mouse as a direction variable... and tweaked the code generated by chatgpt and the origin point of the questick to match my new element, this is the result the blue line follows my mouse at a 100px distance from abll in a perfect circle around the centered cueball ( redball ) .. if find this amazing, especially for new beginners that need their code to be fixed or maybe ask the ai to generate some better code

    ================

    Tagged:

  • GeorgeZaharia

    what is minus?

    minus like in + 100 and -100

  • im guessing timew is a global? and when u die u reset the global variables. including timew. try reseting globals manually, only what needs to be reset or reset the time after u copy the results in a 2ndary data variable that is local or array etc... that doesnt change when u reset the globals.

  • does ur animation has speed set properly? is there a event looping the start of animation over and over under some condition? this 2 main reasons usually are the faults.

  • ur canvas snapshot doesnt go where the sprite is... it takes the center of the screen or layout... try adjusting the canvassnapshot position if there is a function for it.

    based on ur image.... for canvasX use only bboxleft (or image.X) and for canvasY use only image.y

  • use Minus for force or angle ;)

  • You do not have permission to view this post

  • I'm working on a tower defense game and i had a similar problem needed to know which of the enemy / ai that walk the path is the 1st or last... so i used the bullet behavior, set the speed to random values based on type of enemy, so some enemies are faster some are slower, and at some point if my tower shooting sprite has a target already and a speedy AI passes the 1st current target becoming the 1st target, i need to select that now since is the 1st. Bullet behavior has a "distance traveled" parameter, which counts the pixels they move around. and i used that as my distance calculation to automatically target the first AI whenever gets in front of others. but for you not sure if this is a solution it all depends on how u make the AI move, are they moving grid based? etc

    but a simple solution would be to calculate the left and right distance to the edge of the screen of the AI since that is what u need. to identify which is closest to left or right side ...

    hope it helps.

    to pick an enemy u have to run a for each loop

    and compare the distance => distance(enemy.x,0,viewportleft,0)

    which would calculate the distance of enemy ai to left side of screen or something like that. not sure if the viewportleft is correct code but u should see the proper suggestion in the event sheet if u type it in.

  • construct.net/en/free-online-games/pong-3d-39499/play

    Forsted might be able to help u a bit.

  • Object(n).expression lets you pick the nth instance of am object in an expression.

    https://www.construct.net/en/make-games/manuals/construct-3/project-primitives/events/expression

    See the section on object expressions.

    Iirc, this is special in that it can reference the values of an object that isn't currently picked by event conditions.

    There is nothing special about object.anything, as long as object.anything is any expression that returns a number that represents the object instance (n, or iid) you're trying to get at.

    ah ok so it is usable as a identifier of a specific object as long as u know the iid or N custom value u assign it to him. ok that is helpful thanks. also the link u sent doesnt work but this explanation solved my issue. thanks a lot. :D

  • Hi there, long time since i posted around the forums. I searched the forum but couldn't find a result cause i don't know how to call this expression, that is in Construct but never understood what does it do.

    The expression in question is this:

    object(object.anything).x

    the (object.anything) what does it do? identify a certain object? or what is it for?

    im using it as a object identifier of the same type for example:

    i have 5 buttons... all the same sprite just different instances.

    from left to right i assigned a 0 to 4 id to them as i create them in a loop at a start-up to perfectly align them.

    but as u press the button the buttons increase in width to "simulate" it's selected.

    and decrease in width to original width to show that is not selected.

    now i need to calculate the distance from the first to last button in order to perfectly align the object in center based on the gap between those buttons.

    im calculating the distance as distance(button(button.id=0).bboxright,0,button(button.id=4).bboxleft,0)

    this if the expression between the parenthesis is working as im thinking at as a identifier between objects of the same type. then it should give me the exact distance between first and last object. but ...it's short by 20% or so...

    i realize the problem is with me no understanding properly what the (object.anything) expression is for... anyone can explain to me what this thing does? i think i asked before but i forgot was a long time ago 2-4 years ago maybe. Thank you in advanced.

    P.S im looking through the manual to see if i can find it... so far no luck.

    P.P.S i solved my issue another way... but i still don't know what this expression does. If anyone can answer would help a lot.

  • are the sprites on top of each other? it sounds like u are pressing overlapped objects at the same time. the event code should work fine as long as the objects don't overlap. and are different types/names.

    and my all events at the same time u mean the two in the picture im guessing?

    or other events as well? it might be a "touch/mouse" function or just ur cache needing some clearing. try a different browser if above is not the issue or clear cache. sometimes might get buggy if u working for multiple hrs and closing/opening the project a lot of times a day.

    but since ur doing a touch and find missing object, my thinking is u got overlapped objects and the event code u have is missing "identification order" which item should it pick to trigger the even the top or bottom one?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
GeorgeZaharia's avatar

GeorgeZaharia

Member since 30 Jun, 2014

Twitter
GeorgeZaharia has 36 followers

Trophy Case

  • 10-Year Club
  • Jupiter Mission Supports Gordon's mission to Jupiter
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • Forum Hero Made 1,000 posts in the forums
  • x9
    Popular Game One of your games has over 1,000 players
  • x21
    Coach One of your tutorials has over 1,000 readers
  • Educator One of your tutorials has over 10,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Great Comment One of your comments gets 3 upvotes
  • Email Verified

Progress

21/44
How to earn trophies

Blogs

  • Construct For Dummies - Simple Tutorial Collection

    I scour the Construct forums for users tutorial requests, and create small quick and simple tutorials using Construct's defaults features so anyone can use and apply them.

  • My Dev Logs

    Thinking on games 24/7 is fun and waste of time and unproductive if we don't bring those game ideas to life. In this blog im bringing my game ideas to life and log their development process.