zatyka's Forum Posts

  • Play Earth Was a Bad Choice

    You're an alien that was hoping Earth was a nice vacation destination, but quickly found out the inhabitants are hostile. Race to your ship through a flurry of explosions. There's a definitive ending. I hope you get to see it.

    Directions:

    • Press any key to progress the dialog
    • Move left and right with either Arrow keys or A&D. (Touch controls are enabled work if you're on a mobile device)
    • M toggles audio
    • Try and remain airborne
    • Chain explosions for sweet combos

    Here's the game's Ludum Dare page. I hope you enjoy it! Feedback is always welcome. I'm eying this up for Ludum Dare's October challenge.

    Also, check out this thread for other LD games made in Construct 2.

  • C2 game list added to original post. If you put "Construct 2" or "Scirra" or "capx" somewhere in your entry, it should already be on the list.

    If my crawler missed your game, just let me know and I'll add it.

  • Here's my entry:

    Earth Was a Bad Choice

    I'm looking forward to playing through everyone's games.

  • There is no magic bullet. Some people add borders to their layout, some people set object's positions relative to screen size. The correct answer is "it depends on how you've set up your game".

  • Try Construct 3

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

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

    Well, I can think of a few ways to use variables to accomplish this. Let's pretend there are 4 layouts:

    • LayoutD
    • LayoutB
    • LayoutC
    • LayoutA

    Let's make a variable called "AllLevels", and set it to "DBCA":

    var AllLevels = "DBCA"[/code:23l96eti]
    
    We're going to use a method to do the following
    
    [ul]1.  Pick a random character (i.e. one of the letters) from AllLevels, and save it to a variable
    2.  Remove the character from AllLevels
    3.  Go to that picked layout[/ul]
    
    We're going to leverage the Len(), Random(), Floor(), TokenAt(), and Replace() expressions.  Here's their definition from the manual:
    
    [ul]
    [b]len(text)[/b]
    Return the number of characters in text.
    
    [b]random(x)[/b]
    Generate a random float from 0 to x, not including x. E.g. random(4) can generate 0, 2.5, 3.29293, but not 4. Use floor(random(4)) to generate just the whole numbers 0, 1, 2, 3.
    
    [b]floor(x) [/b]
    Round down x e.g. floor(5.9) = 5
    
    [b]tokenat(src, index, separator[/b])
    Return the Nth token from src, splitting the string by separator. For example, tokenat("apples|oranges|bananas", 1, "|") returns oranges.
    
    [b]replace(src, find, rep)[/b]
    Find all occurrences of find in src and replace them with rep.[/ul]
    
    Alright, just to reiterate, the first step is to pick one of the random characters (i.e. letters) from the AllLevels variable.  To do that, we first need to know how many total characters there are in the string.  That's where the Len() expression comes in handy.  Let's get the length of AllLevels, and stick it in a variable called "StringLength":
    
    [code:23l96eti]
    var AllLevels = "DBCA"
    var StringLength = Len(AllLevels)
    [/code:23l96eti]
    
    Right now, the string is 4 characters long.  Since Construct 2 uses 0 based indexes, those 4 characters correspond to index 0 (D), 1 (B), 2 (C), and 3 (A). We need to randomly choose one of those indexes.  To do that, we'll use the random() and floor() function, and stick the random index into a variable called "RandIndex".
    
    [code:23l96eti]
    var AllLevels = "DBCA"
    var StringLength = Len(AllLevels)
    var RandIndex = floor(random(StringLength))
    [/code:23l96eti]
    
    Now that we have our random index, we need to get the character at that index from AllLevels.  To do that, we'll use the tokenat() function, and assign the results to a variable called "SelectedLevel"
    
    [code:23l96eti]
    var Allevels = "DBCA"
    var StringLength = Len(AllLevels)
    var RandIndex = floor(random(StringLength))
    var SelectedLevel = tokenat(AllLevels,RandIndex,"")
    [/code:23l96eti]
    
    Ok, we have our letter, and we'll go to the appropriate layout in a moment, but let's first remove the SelectedLevel from AllLevels, so the process doesn't pick it again later.  There are a couple ways to do it, but let's use the Replace() expression.  
    
    [code:23l96eti]
    var AllLevels = "DBCA"
    var StringLength = Len(AllLevels)
    var RandIndex = floor(random(StringLength))
    var SelectedLevel = tokenat(AllLevels,RandIndex,"")
    var AllLevels = replace(AllLevels,SelectedLevel,"")
    [/code:23l96eti]
    
    Finally, let's go to the selected Layout.
    
    [code:23l96eti]
    var AllLevels = "DBCA"
    var StringLength = Len(AllLevels)
    var RandIndex = floor(random(StringLength))
    var SelectedLevel = tokenat(AllLevels,RandIndex,"")
    var AllLevels = replace(AllLevels,SelectedLevel,"")
    Go to Layout by name "Layout"&SelectedLevel
    [/code:23l96eti]
    
    There you go.  Repeat the process whenever you need to go to another Layout.   You should now know how to use variables to go to a random, non-repeating stage.  We're done here, right?
    
    [h2][b]NO![/b][/h2]
    
    This is convoluted and problematic.  For example, it won't work for more complex Layout names?  The bottom line is that variables are a poor way of selecting random non-repeating values.  Variables are meant to hold 1 value, not a series of values.  Sure, you could make it work, but they're not the right tool for the job.  Arrays, on the other hand, are far more appropriate.  Arrays are, by definition, a series of values.  They're also far more flexible, and easier to manipulate.
    
    I'm assuming you're asking how to use variables in this scenario because you're not sure how to use arrays.  Well, if you were able to follow along with the above steps, you can use arrays because it's pretty much the same process. Here's how to use the exact same method with Arrays:
    
    Set the size of the array to 0,1,1.  This empties the array, but makes it ready to receive a list of values.
    [code:23l96eti]
    Array Size = 0,1,1
    [/code:23l96eti]
    
    Insert the different layout values to the array.  I'll use just the letters to remain consistent with the previous method, but you could just as easily use the full Layout names.
    [code:23l96eti]
    Array Size = 0,1,1
    Insert "D" into Array
    Insert "B" into Array
    Insert "C" into Array
    Insert "A" into Array
    [/code:23l96eti]
    
    Determine a random index based on the width of the array.  No need to use len().
    [code:23l96eti]
    Array Size = 0,1,1
    Insert "D" into Array
    Insert "B" into Array
    Insert "C" into Array
    Insert "A" into Array
    var RandIndex = floor(random(Array.Width))
    [/code:23l96eti]
    
    Get the value stored in the array at the random index.  No need to use Tokenat().
    [code:23l96eti]
    Array Size = 0,1,1
    Insert "D" into Array
    Insert "B" into Array
    Insert "C" into Array
    Insert "A" into Array
    var RandIndex = floor(random(Array.Width))
    var SelectedLevel = Array.at(RandIndex)
    [/code:23l96eti]
    
    Delete the index from the array.  No need to use replace():
    [code:23l96eti]
    Array Size = 0,1,1
    Insert "D" into Array
    Insert "B" into Array
    Insert "C" into Array
    Insert "A" into Array
    var RandIndex = floor(random(Array.Width))
    var SelectedLevel = Array.at(RandIndex)
    Delete index RandIndex from Array
    [/code:23l96eti]
    
    Finally, go to the selected layout:
    [code:23l96eti]
    Array Size = 0,1,1
    Insert "D" into Array
    Insert "B" into Array
    Insert "C" into Array
    Insert "A" into Array
    var RandIndex = floor(random(Array.Width))
    var SelectedLevel = Array.at(RandIndex)
    Delete index RandIndex from Array
    Go to Layout by name "Layout"&SelectedLevel
    [/code:23l96eti]
    
    Check out the capx I posted above.  If you made it to the end of this unexpectedly/unnecessarily long post, I bet you can understand the capx now.  Like I said earlier, Arrays are extremely useful, worth learning, and in this case, the best solution.
  • That makes sense. Thank you.

  • Look for function atan2 which takes dy and dx as parameters.

    Just to add onto this, the atan2 function will return radians. To get to degrees, multiply by (180/pi):

     var degrees = Math.atan2(y2-y1,x2-x1) * (180/Math.PI);[/code:jyyxq4ol]
    
    You could have undoubtedly found this solution by googling "Calculate angle between 2 points in javascript".
  • My "I'm In" video.

    In case you couldn't tell, I get pretty hyped about Ludum Dare.

  • phimaka

    That may be a workaround for the capx I posted, but that doesn't resolve the issue. The issue persists even if the object's global flag is set to "No". Using a create action should create an instance regardless of whether the object is global. In the workaround you provided, the correct result should be 2 global objects.

    Also, since this doesn't occur on r208, I'm guessing this was unintended behavior introduced in one of the last few betas.

  • Problem Description

    "Create Object" action not working upon start of layout.

    Attach a Capx

    https://drive.google.com/file/d/0B1WHy6HMPuyoMWY2Yk0wbmtzaWc/view?usp=sharing

    Description of Capx

    Capx contains 2 layouts and 1 event sheet. The "Object Repo" layout contains a single object called "global". The "Loading" layout contains no objects, and is tied to event sheet "ES Global". The "ES global" event sheet contains a single event that creates a "global" object upon the start of the layout.

    Steps to Reproduce Bug

    • Run preview of the "Loading" layout

    Observed Result

    No "global" instance is created.

    Expected Result

    An instance of the "global" object should be created.

    Affected Browsers

    • Chrome: (YES)
    • FireFox: (YES)
    • Internet Explorer: (YES)

    Operating System and Service Pack

    Windows 8.1

    Windows 7

    Construct 2 Version ID

    r211

    Note: This issue does not appear in r208. I rolled back just to confirm.

    I repeat: €330. I expect this to be built-in. Why shouldn't i?

    PC Gamepads have a standardized web API. Virtual controlers do not. Anything built-in would likely pigeonhole your control scheme.

  • Results are in.

    Congrats to everyone who participated. Ludum Dare 34 is scheduled for 12/11 - 12/14.

    (If my crawler missed your game, just let me know and I'll add it.)

    C2 Compo Games:

    C2 Jam Games:

    "What is Ludum Dare" you ask?

    Ludum Dare is an accelerated game development event held every 4 months. Thousands of developers create games for two concurrent competitions taking place over 1 weekend. Full competition rules can be viewed on Ludum Dare's webstite, but here's a summary:

      Compo
    • 48 hours long
    • You must work alone
    • You must use the competition theme
    • All game content must be created within the 48 hours, with a few exceptions (see full rules)
    • Publicly available libraries and middleware (e.g. Construct 2) are allowed
    • Source Code must be included when submitting
      Jam
    • 72 hours long
    • Work alone or in teams
    • All creation tools are allowed

    At the end of the weekend, entrants rate eachother's games for 3 weeks. Winners are announced at the end of the rating period.

    Why should you participate?

    Many reasons:

    • It's fun.
    • You'll join a great community of developers.
    • C2 is, in my opinion, perfectly suited for Ludum Dare.
    • Making it to the end, and submitting a game provides a great sense of accomplishment.
    • It will make you a better developer. Testing your game creation abilities under tight conditions, with a strict deadline, is like a game development adrenaline shot. It's a serious learning experience that will test your existing skills, and force you to rapidly develop new ones.

    Let's get the excuses out of the way

      "But I can't afford to participate." It's free. "But I don't know how to make a game." Download C2, go through some tutorials, and play around with the software. You'll quickly realize that creating a game much more possible than you think. "But 2 or 3 day is too short a time to create a good game." Long, in-depth, gaming masterpiece aren't possible, but you can absolutely create an awesome game. I dare you to play some of the winning Ludum Dare games (see below), and tell me they aren't awesome. "But I already have plans that weekend." Challenge yourself to create the best game possible in whatever time you have available. My LD29 entry was created in 2 hours. It's not particularly ***** but I'm quite proud of what I created in 2 hours. "But there aren't any prizes." Monetary prizes... no. The prize is the experience and the game you produce. It's not uncommon for participants to further develop their entries into commercial products. Speaking from personal experience, professional opportunities have come my way both directly and indirectly from participating in Ludum Dare.

    Here are a few links you may find useful/interesting:

    • Ludum Dare Survival Guide - Great tips, especially if this is your first Ludum Dare.
    • Tools - A nice collection of popular tools used by many Ludum Dare participants.

    Not hyped yet?

    Go play some games from the previous Ludum Dare:

    I hope I've convinced a few of you to participate. Best of luck to everyone.

  • I would use an array to record the head's position and angle, and use that data to set the body segments.

    example

  • I'm assuming you're creating a single trail object per tick. If the moving object travels a distance longer than the size of the trail object, you'll get gaps. To compensate, you need to calculate the distance traveled between ticks, and create multiple trail objects along the movement path.

    Example

  • Thanks, really if it seems complicated.

    Perhaps someone has a different and simpler method.

    Arrays aren't complicated, but like many data structures, can be a bit hard to conceptualize at first. They're extremely useful, worth learning, and in this case, the best solution.

    Example