Pandy's Forum Posts

  • Hey guys,

    Iv'e been trying to make a snake ai with C2. I saw that gif where the snake ate all the food and ended up filling the whole screen with itself and thought of replicating it.

    I'm having trouble trying to make the snake avoid running into it's own tail.

    I can avoid this if the snake is directly facing a tail segment with the help of line of sight behavior but not when the snake is right next to its own tail not facing it's tail segment.

    I have conditions where 'if food.X greater than snake.X => move right' and so on for all directions for the snake to move automatically. The tail is a square segment which is spawned when 1 food is eaten

    (Take example where the snake is moving up/down and has to move right to get it's food)

    The problem is avoiding the snake from moving right if it has a part of it's tail to it's immediate right, and only move if it's clear.

    If i put a condition 'check if tail is snake.X+10' , the system checks for all the tail parts and even if one tail part is not snake.X+10 the condition lets the snake move even if another tail is snake.X+10.

    Using picked instances makes the snake not move at all for some reason, i think it's cause if no tail meets the picked condition the condition to make the snake move is not met.

    Can anyone help?

    Thanks

  • matthewhxq

    That error usually pops up when previewing over lan. It wouldn't occur on the compiled version of your project. I think.

    Can anyone confirm.

  • In the multiplayer tutorial examples, the peer and host are basically interacting and seeing the same things as the other player is seeing.

    I want to know if we can make a multiplayer game where maybe the host can see some things which the peer can't and vice versa.

    For example take a game where player1 has to run across the screen and avoid mines planted on the ground.Now we want player 2 to be the one planting mines and he can do this by clicking on the screen and a crosshair as an aiming aid.

    Now we want player1 to only see the main character sprite and player 2 to be able to see the main character sprite and the crosshair.

    Basically want i'm asking is are we restricted to host and peer seeing the same thing or can they have different perspectives on what's going on during gameplay.

  • I mean, say there is a game and P1 is the host and P2 becomes the peer. They play the game and then say for round 2, can we make P2 the host and P1 the peer?.

    Imagine a dodgeball game where P1 controls the player and P2 taps on screen somewhere to spawn a ball at that point and for round2 P2 becomes the player and P1 controls the ball. I was thinking about the lag that may occur and cause an unfair advantage to the host due to the inaccuracy in position that may occur when P2 controls the player.

    Is it possible?

  • BluePhaze

    What about cocoonjs compiled apks?. Can it work on android devices.

  • Is there a plugin or anything that makes it possible?.

  • That's weird. Does it only occur on mobile? or does the penguin pass right through in desktop as well? Does it happen for the popsicles too?. You exporting using cocoonjs?.

    It seems fine when i tested on my android.

    You sure you didn't change the code, The for each block loop is still present right.

  • Ha sorry but i'll need more time to understand how all those variables play together. You can keep trying new ways and testing. That's the best way to learn.

    If the game works as it is i wouldn't really bother with trying to optimize the event sheets. The performance gains you'll get is really negligible compared to the gains you'll get from removing unnecessary events, objects, collisions etc.

    If you are gonna use cocoonjs, export the project with version 1.4.7 rather than their 2.0.0 beta. Performance is definitely better in the older version.

    If the game works as it should at 60 fps on mobile, publish it and then iron out your event sheet for future updates.

  • Here you go.

    I have completely removed the need for collisions in your game. I added events where you compare positions for the penguins and the block and Popsicle. Added comments so you can get an idea how i did it.

    You seem to have a snow hitbox items which i don't know what it's used for. I left it as it is but it had collisions enabled and it will effect performance.

    You can definitely improve more by yourself. Check the forums, tutorials, destroy objects that are not needed on screen, reduce the particle numbers in your particle object if you can it's a known performance downer

    If you can add a blue outline to the score text, makes it easier to read

    Get back with how much better fps you get

  • What does your debug read in terms of collision count. I'm sure you can make the game without the need for collision checks. Try using the overlapping event and disable collisions for everything. The particles object is known to reduce fps count. Test test test in debug.

    Honestly it's easier to read an event sheet from a capx file. You can pm the capx if you want, i have some free time atm

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Aphrodite

    Ah thanks a lot, i didn't think about looking at project settings, i just mucked about project properties and thought the option wasn't there. Thanks again.

  • Ok my games got 3 layouts and one of them is a splash screen and as with splash screens i want it to be the first layout shown on mobile. After i compiled my project with Ludei cloud compile service and previewed on my phone, the game starts of with Ludei's splash screen and then goes to my game layout, completely skipping my splash screen.

    How do i make sure my splash screen is the first layout of my game when exported to cocoonjs and previewed on my phone?. I did create my splash screen layout last, not sure if that has anything to do wit it.

    Anyone?.

  • Using events that disable the drag and drop behavior of the object, stops the object. But it'll also make it immovable afterwards. So you have to add events that will re-enable the drag and drop again.

    Not sure if this will work but try this anyways.

    Make an event where the conditions are

    -Gold bar is above the brick bar(that is gold.Y is less than brick.Y as Y decreases as you go up)

    -Brick is overlapping gold(brick comes in contact with gold, similar to collision)

    Make an action where it disables brick drag and drop.

    Now this will stop the brick in it's tracks but you'll notice you cant move it anymore.

    Now this might only work if you have preview over lan to your phone cause you'll have to use the touch objects accelerometer option. By seeing if you swipe up or down you'll get positive or negative values for the accelerometer value.

    So say if you swipe up you get a negative Y accelerometer value (i'm not sure if it's negative or posotive, you'll have to find it out) So what you can do is add the condition(to the one i already mentioned) 'touch Y accelerometer value is less than 0 i.e negative. So now if it works it'll still disable movement if you swipe up and the gold is above brick

    Now to reenable movement , you make another action where conditions are

    -Gold above brick or Gold is not right below brick

    -Brick is overlapping gold ( if it is already overlapping )

    -touch Y accelerometer is greater than zero i.e positive

    And the event is, enable drag and drop for brick

    So now if this method actually works, when you swipe down and the gold bar is not below the brick, it should re-enable movement.

    Touch accelerometer does not work on desktop. So i'm not sure if this will work at all. Sorry

    Obviously putting Gold above brick conditions is not the only one, if the gold is to the far right and the brick is to the far left , it'll still disable movement even tho gold is not right above brick, so you have to add other conditions like comparing distance between the two.

    Please look around the tutorials, search for keywords, cause there will definitely be a more simpler and working answer.

  • Hmm mind uploading a capx?. Checked the debug to see if the objects are pinned while running the game?.

  • Did you try using the pin behavior. Pin object1 to object2 , position and angle.