dop2000's Recent Forum Activity

  • You can use distance() expression.

    Something like this:

    Every 0.5s -> NightBlock set opacity to lerp(80, 0, distance(planet.x, planet.y, sun.x, sun.y)/200)

    If the planet is more than 200px away from the sun, opacity will be 0.

    As the planet moves closer, opacity will increase up to 80.

  • The easiest solution would be making a bigger collision box (by the way, the collision polygon in your red line sprite is wrong).

    Or put a bigger invisible sprite for swipe detection.

    Or you can make a more complex system - on touch start remember the coordinates and time, then on every tick as the touch continues, check if new touch coordinates are on the other side of the line. If this happened quite quickly, then you can assume that there was a swipe gesture across the line.

  • Can you post a screenshot of your code?

  • Hey, no problem! I happen to have some free time and I enjoy helping people on this forum, by doing this I feel like I'm learning a lot of new things myself and getting better at game development.

  • 20-60 second delays are quite long, so forget about using "Wait" action.

    Add Timer behavior to one of your objects (background sprite for example) and a variable "callCounter".

    Then you can do something like this:

    On start of layout
    [ul]
    	[li]> Sprite start Timer "CallFunction" for random(20, 60)[/li]
    [/ul]
    Sprite On Timer "CallFunction" 
    callCounter<3 
    [ul]
    	[li]> Add 1 to callCounter[/li]
    	[li]> Sprite start Timer "CallFunction" for random(20, 60)[/li]
    	[li]> Function call ...[/li]
    [/ul]
  • Yes, of course you can set the value to some variable.

    Dictionaries are perfect for use together with local storage, because you can easily save and load a lot of information at once.

    If you are saving each variable separately in LocalStorage, you need a million of events to save and retrieve each item. If you are saving a dictionary, you only need a couple of events.

    .

    I also suggest keeping dictionaries not just to store data in local storage, but actually using them in your game. For example, you can have a dictionary GameSettings, with keys like "MusicVolume", "SoundVolume", "Difficulty" etc.

    You don't need to create variables with the same data, just use the dictionary, for example:

    Audio set volume to GameSettings.Get("MusicVolume")

  • Global variables are not always evil, but in this task (where you need them to store information about lots of objects), they are a very bad choice.

    Instance variables is a good choice for this task, they are much more efficient. You can have 100 items and only 10 instance variables to store all items properties. (With global variables you would have to create several hundreds of them and many-many more events)

    .

    If you have multiple of sprites with similar features, you need to combine them into a family. If you have, or planning to have sprites Player1, Player2, Player3, Player4 - add them to FPlayer family and move all instance variables, all behaviors from sprite level to family level. This will save you a lot of time and efforts in the future and you could organize your code better. For example - instead of four almost identical events "On player1 jump - do something..." you can create just one event "On FPLayer jump".

    .

    I recommend doing the same with items - you can make an individual sprite for each item, but you need to combine them all into a family.

    Individual sprites are probably even better for this job. You can keep them all on a separate (unused) layout "ItemsInstances", fill in all the values into their instance variables. And this will become your database of all items and their properties. When you spawn an item in the game, it will be created with all those properties you defined.

    .

    Don't worry about the Save feature, it saves everything - global variables and instance variables.

  • You can check if multiple points under the character are overlapping the ground or not. Depending on which points are overlapping, adjust the character angle and angle of gravity.

    Another possible solution would be adding invisible sprites (circles, rectangles) to the layout. When character is overlapping these sprite, set its angle to sprite center, or away from it.

  • So many questions..

    If you have lots of different items with lots of properties and you want to generate one at random, you need an organized way to store all this information. Lets call it the database. In C3 probably the easiest way to do this is with arrays (because of the Array Editor).

    My example project has this database, you can add more items to it and more properties, just need to create functions to retrieve them. You can have multiple arrays (say, one for weapons, another for consumables).

    .

    .

    Here is how you can do this without any database:

    If you were placing all these items manually onto the layout (for the character to find), you can store all information directly in sprites.

    Create a few sprites - Weapons, Potions, Food, Tools (or Basic, Legendary, Rare, whatever) with multiple animations.

    Add them all to ITEMS family, and define a bunch of instance variables on the family, for all possible items properties - "damage", "run_speed", "jump_strength", "price" etc..

    So when you place these sprites on layout, you will need to manually set an animation and enter values into these instance variables.

    E.g.: animation="small_sword", damage=10. Leave unused variables empty.

    .

    So how do you give a random item to the player?

    You can put all these items off-screen, all hundreds or them.

    When player picks up a Randomizer, select a random instance of ITEMS family and move it to player's position.

    .

    It's your game, so you should decide how are you going to do this.

    One thing I know for sure is that making hundreds of global variables to store all this data is definitely a bad idea.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Dictionaries are actually very simple, much easier to understand than arrays.

    They are like variables, only more flexible. Just add keys and values, for example:

    Key="Coins", value="35"

    Key="Weapon", value="small_sword"

    etc.

    .

    Then save to local storage Dictionary.AsJSON

    To load: Dictionary load from JSON (LocalStorage.LastData)

    .

    I made this demo for some other post:

    dropbox.com/scl/fi/sz1qjsd9c40p9il1iahx4/DictionaryLocalStorage.capx

  • dt is the frame duration.

    If your game runs at 60 FPS, dt is approx 0.017s

    So 50*dt=0.83

    .

    At 50 FPS, 50*dt will =1

dop2000's avatar

dop2000

Member since 26 May, 2016

Twitter
dop2000 has 257 followers

Connect with dop2000

Trophy Case

  • 8-Year Club
  • Entrepreneur Sold something in the asset store
  • 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
  • Forum Wizard Made 5,000 posts in the forums
  • Forum Unicorn Made 10,000 posts in the forums
  • x5
    Popular Game One of your games has over 1,000 players
  • x2
    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
  • Steady Visitor Visited Construct.net 30 days in a row
  • Enduring Visitor Visited Construct.net 90 days in a row
  • Unrelenting Visitor Visited Construct.net 180 days in a row
  • Continuous Visitor Visited Construct.net 365 days in a row
  • RTFM Read the fabulous manual
  • x3
    Quick Draw First 5 people to up-vote a new Construct 3 release
  • x13
    Great Comment One of your comments gets 3 upvotes
  • Delicious Comment One of your comments gets 10 upvotes
  • Email Verified

Progress

28/44
How to earn trophies