zatyka's Forum Posts

  • Two problems:

    1. The coordinates of image point 1 on the player object are way off (-110,-270). Moving the image point in front of the player should fix this.

    2. You're spawning the bullets on layer 0, which has a parallax of "50,50". Changing the parallax of that layer to "100,100", or spawning the bullets on layer 1 should fix this.

    I made those changes, and the bullets fired correctly.

  • Pretty neat. It reminds of a little project I worked on a few months ago. It's fun figuring out how to program different drawing tools.

  • You can make this a little easier if you name all the music similarly. For example, if you name the music:

    Music0

    Music1

    Music2

    Music3

    You could play one of them randomly by using the "Play(By Name)" action:

    Play "Music"&Floor(Random(4))

    Of course, naming music similarly isn't always a viable the best option.

  • Edit:

    Never mind. Pretty much what Tokinsom said :)

    Static rotation on the left. AngleLerp used on the right.

    Capx

  • Here's one way to do it. It's similar to the method Guizmus suggested, but uses an array instead of a string variable.

    Demo

    Capx

    I hope this helps.

  • The simplest solution is to add an instance variable to the bullet object (e.g. "SourceID"). Whenever a bullet is create, set the instance variable to the UID of the object it was spawned from. Then, whenever the bullets hits something, you can use the "Pick by UID" condition to find its source based on the bullet's instance variable.

  • Another option would be to create your own pinning system using events. You'd have to use a bit of trig, but it should give you the flexibility you need to position objects based on a loaded objects center origin.

    Having said that, I think GeometriX's suggestion of using an invisible object would work just as well, and be much simpler to implement.

  • I think I missed your attempt to use my method. I did a quick edit to your recent capx to show you how to use zones.

    Capx

    A few things to note:

    • The capx will seemingly only work for horizontal scrolling, but that's becasue you have the window size much larger than the playable area. My method works best when the zones height and width are equal or larger than the game's window size.
    • I had to change the some of the numbers in the scrolling event to correspond to your game's windows width and window height. I'm guessing this is where you may have run into trouble before. I changed the numbers to correspond to your game's window width and window height divided by 2. If you change your game's window size, you'll need to update these values. Alternatively, you could use the expressions "WindowWidth/2" and "WindowHeight/2" to set these, but as I recall, things can sometimes get buggy on certain full screen modes (thought that may have changed with some recent updates).
    • <img src="http://i.imgur.com/2xDnp8H.png" border="0">
    • Although I didn't test it, I'm sure ErekT's method would work fine. Personally, I don't like creating camera objects, but that's just me. One benefit of using the zone method is automatic transitions between zones.
    • A more detailed explaination of what the event means can be found approximately 2/3 of the way down this post.

    I hope this helps.

  • Here's an example I made for another topic, but it should apply here as well. The method uses zones to define the camera's limits. The camera will follow the hero as long as it's within the hero's current zone.

    Demo

    Capx

  • You could just set the angle of motion to "angle(bullet.x,bullet.y,player.x,player.y)".

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The math used in my demo isn't nearly as hard as it may look. Here's an explanation of what's happening.

    Let's start with the camera following the hero:

    <img src="http://i.imgur.com/BoztZOP.png" border="0" />

    Now we want to confine the camera to be within the zone the hero is currently in. Let's use the clamp expression to limit the scroll to positions:

    <img src="http://i.imgur.com/7yXTky5.png" border="0" />

    So what does this mean? Let's use the X coordinate as an example: clamp(hero.X,zone.X+160,zone.X+zone.Width-160)

    This expressions returns the value of hero.x as long as it's in between a minimum and maximum value. Otherwise, the minimum or maximum value is returned.

    When testing for minimum and maximum values, we need to keep 2 things in mind:

    • The origin of each zone is in its top left corner.
    • The width of the window is 320 pixels.

    Setting the minimum value stops the camera from going beyond the left edge of the current zone. It's set to Zone.X + 160. Zone.X is the left edge of the zone, and we must add 160 to compensate for half the width of the window.

    Similarly, setting the maximum value stops the camera from going beyond the right edge of the current zone. It's set to zone.X+zone.Width-160. Zone.X + Zone.Width is the right edge of the zone, and we must subtract 160 to compensate for half the width of the window.

    This expression alone will make a very choppy transition from one zone to the other, so let's throw in a lerp. This allows for smooth scrolling when changing zones.<img src="http://i.imgur.com/tmpDv7o.png" border="0" />

    Every tick, the lerp expression moves the current scroll 10% closer to the to the calculated scroll position (the result of the above clamp expression).

    I hope this explains things a bit more. Regarding non-rectangular zones, it's going to be difficult to have the camera scroll correctly around corners.

    <img src="http://i.imgur.com/ywIzEOP.png" border="0" />

    To accomplish this, you'd need a much more complex camera system, smart enough to recognize when it needs to move around corners based on the players movement.

  • Using the method in my example, you could overlap 2 zones for a T-shape, but the transition won't be as slick. It does get trickier if you want the camera "rails" to change directions smoothly.

  • I believe I understand what you're looking for. Here's one way to accomplish the effect using zones:

    Demo

    Capx (r131)

    The method I used will only work for rectangular zones. I hope it helps

  • There are family instance variables, but they're not quite the same thing.

    They function the same as far as I know. A family instance variable sounds like the ideal solution to the problem you described. Do you have a specific scenario where a family instance variable would not be a viable option?

  • You'd need some way of syncing real-world time with a source outside of the game. There are 2 plugins that get the system date an time on the user's computer:

    Clock

    System Date and Time

    If you're concerned that the user would cheat by messing with their system clock, you can sync with an external source to get the correct time, but this is a bit more complex. If you have your own server, you can get the time by setting up a simple PHP script. Then, within the game, ajax request the php page.

    Once you have a method of getting the current time, all you'd need to do is record the time the item is acquired, and destroy the item if more than an hour or more has passed.