Screen Shaking and Game Freezing

BagzliBagzli Member, PRO Posts: 48

Hi,

I'm trying to make a room where few actors will move randomly within it. So my approach is as follows:

Created 10 points on the map
created table with 2 columns and 10 rows and then plotted the x and y locations of the 10 points on the map
created a rule on the actor,
I added 3 attributes to the actor, speed, Total Points and Direction all of type Real
Created a timer on the actor
Every 5 seconds
Action 1: Change Attribute
Self.Direction to random(1, self.Total Points)
Action 2: Move To
tableCellValue(game.Room 1 Positions, self.Direction, 1), tableCellValue(game.Room 1 Positions, self.Direction, 2) relative to scene at speed of Self.Speed
Action 3: Display Text
Display Self.Direction

I have done it this way after my first attempt did the same thing, instead of a timer I had Collision with another actor (10 actors that are being used as plot points).

The results with the timer method that I am getting is, game starts, after 5 seconds game screen starts shaking and everything in the game freezes

The results I get with the collision is when game loads, the game is flashing darker to lighter at me and everything is frozen.

I am using windows creator 13.3 and the 13.7 Viewer to test this on my samsung galaxy s4 OS version is 5.0.1

Does anyone knows how I can achieve the above without crashing the game?

Comments

  • RowdyPantsRowdyPants Member Posts: 465
    edited May 2015

    @Bagzli Ideally you'll want to 'Interpolate' the actor positions.

    I'll show a method using interpolation. Let me know if you need a 'Move To' method.

    Create a game level attribute to control when they move (optional). Since we only need this attribute to toggle between two states a boolean attribute will be just fine.

    Go into your actor that will be moving. Create a rule that checks if your game level attribute is true. Inside that rule create a timer that will interpolate the X position and Y position of the actor every few seconds.

    Remember, you can control all of these input values.

    You could have your timer go off every random(min,max) seconds where 'min' and 'max' are attributes or cells in a table or both (using attributes to determine which table cells). Of course you can also interpolate to these functions as well. You could even use device attributes to generate random coordinates to send the actor to.

    After giving your rules to one actor drag however many instances you want into the scene. You can always change the image each instance uses or other self attributes to individualize them.

  • RowdyPantsRowdyPants Member Posts: 465
    edited May 2015

    @Bagzli Here's a 'Move To' method. I think you're wanting something closer to this.

    Create the same game attribute (boolean is fine) to control when they are allowed to move.

    Go into your actor that will be moving. Create three self attributes.

    Create these rules.

    Using this method will allow each actor to totally stop and start moving independently because they're on their own self timers. And you can easily toggle animation so that they only animate when moving.

    When setting self.targetX and self.targetY attributes you could use table cell values or device attributes to find a random spot within the screen. Use the third expression in my last post. Use game.Screen.Size.Width for the x coordinate (self.targetX) and use game.Screen.Size.Height for the y coordinate (self.targetY). It may look complex but that third expression basically reads 'half the width of the screen' (the center of the screen) + a random number between 'negative half the screen' and 'positive half the screen'. So, somewhere on the screen :) I added the actor's width onto the min value and subtracted the actor's width from the max value to keep it on the screen. You can use the actor's height when setting the 'y' one to keep self.targetY being changed to only somewhere on the screen (vertically).

    To clarify the photo, the animation is happening only when
    self.Motion.Linear Velocity.X or self.Motion.Linear Velocity.Y
    are not equal to 0.

    I made a demo project for you to download

    Hope this helps!

Sign In or Register to comment.