Johncw87's Forum Posts

  • re: "Not possible"

    I agree. With the right parameterization it can be done, but it would involve other tradeoffs, such as larger event sheets and more parameterization -- which makes the code less understandable.

    re: duplicate code

    I surely understand the "evil" of code duplication. However, during prototyping, code duplication can save significant time and cost -- even if i systematically need to make changes across several event sheets -- and I have to do this rather frequently. These event sheets are btw easy to spot since code duplication is only needed for very similar layouts -- such as when "AB" testing layouts ...

    Well, at the beginning of this very thread, you asked for advice on production quality code, and that's what I'm giving you. And I beg to differ on parameterization making it less understandable. Consider the example I edited in to my previous post.

  • Since the quiz I am constructing has layouts that are significantly different its not possible to have a common event sheet for all. Instead, I turned it around, extracting commonalities to sheets included in all layouts.

    It is very likely that you can, in fact, use the same event sheet for all of your quiz layouts, despite them being "significantly different". The levels in Super Mario World are "significantly different", and yet they all use the same code to run them. "Not possible" is a rather bold claim, one that likely wouldn't stand if you were to post your capx.

    I rather duplicate code than write parameterized code.

    I strongly disagree. Code duplication is one of the evils of programming.

    If you need to fix a bug, or change how it works for any reason, you have to remember to do it in all the places where you copied it. You will inevitably miss a spot or two, and have bugs that you already fixed show up in very specific situations.

    "Parameterized" code is also better for readability. What is easier for you? Reading this:

    sqrt((Player.X - Enemy.X)^2 + (Player.Y - Enemy.Y)^2)

    Or this:

    distance(Player.X, Player.Y, Enemy.X, Enemy.Y)

    With the distance function, just glancing at it tells you what it does. With the formula code, you have to spend more time on it figuring out what it does.

  • 1. Internationalization

    My quiz needs to work in more than one language. At this stage I developed a simple but not too efficient solution for that. What do professionals do in cases like this.

    The Source engine (which is used for several first-person shooter games) references multi-language strings with special identifiers. Day of Defeat has one that looks like this: #Dod_Join_Team. An external language file is used to replace the identifier with the language specific string. For Construct 2, I think you should use a dictionary object, whose keys are the language identifiers, and the values are the language specific string. Load the dictionary contents from an external file (such as lang-en.json, lang-es.json, lag-de.json, ect). Then, at the start of every layout, retrieve the language string from the dictionary and use it in the text objects.

    2. Dealing with common pre- and post- processing during each game segment.

    In the quiz there is code that needs to run before and after every quiz screen, example, to start and end timing the quiz length of time. I am currently using a call back feature and include sheets, and a guideline how to construct a main event sheet (always e,g, include eventsheet pre-post). Are there better ways to do this

    You should try to have all of your quiz layouts using the same event sheet, with any differences that are needed specified in the layout in some way. Since layouts don't have variables, I create an object specifically for this purpose (I call it 'LevelProperties'). Give it some instance variables, and configure them as you see fit for each layout. Have your events reference these variables to handle the differences.

    3. Global variables

    It turned out that I have a lot of global variables. I am not sure this is good practice. Do professionals avoid global variables, if yes are there different techniques for that (i know of static local ones, is this used extensively)?

    Personally, I try to avoid global variables whenever possible, since they clutter up the combo box for selecting a variable. If you can get away with using a local, do so.

  • Event sheets also have this problem. If you collapse an event or group, then it writes a collapsed="1" attribute into the event sheet xml. This belongs in the uistate.xml.

  • If your sprite is a global object, you will probably need an explicit event telling the pathfinding behavior to regenerate the obstacle map when the new layout starts. You will also need to do this if an obstacle is moved, created, or destroyed.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I uploaded something to the Arcade, only to find that the json file I was using with the AJAX plugin didn't work. So I created this test:

    http://www.scirra.com/arcade/example/17594/ajax-test

    The problem seems to be that while the json file passes the file whitelist, it never ends up on the server. This link is a 404:

    http://static1.scirra.net/arcade/games/17594/test.json

    As a side note, txt files are not on the whitelist, and I find that a tad silly.

  • Fimbul

    I like this idea, though I think "Variable Namespaces" would be a more appropriate name.

  • KFC

    That's what I currently do. But there have been occasions where I've needed to change the properties of a layer (or add a new one) to a non-trivial amount of layouts. Most recently, I changed how transitioning to/from solid colors worked so that it didn't require webgl, and I needed to add a layer to about 100 layouts, as well as remove the webgl effect from those layouts. It would have been far simpler to just create the layer from events, so I don't have to do that repetitive work. Why do repetitive work when the computer should be able to do it?

    Additionally, if you have a game with a level editor, a user may want to make a level with more parallax backgrounds than you have layers in the layout that loads the levels.

  • zenox98

    DUTOIT

    It seems both of you missed the part where I mentioned that I'm already creating the objects via events. I want to create the layers as well as the objects via events.

  • While working on a project, I find that I create several instance variables whose values get set by events while the game is running, and have no purpose being configured in the layout editor. At the same time, those same objects will have a couple variables that DO need to be configured in the layout editor, and those runtime-only variables clutter up the properties window and get in the way. It would be great if I could hide those runtime-only variables from the layout editor, so as to avoid confusing other people who also work on the project.

    This is pretty minor in the grand scheme of things, but would still be nice to have.

  • I'm working on a project with a lot of layouts, and most of those layouts share certain elements (like the UI). I use events to create all of the objects for those elements (so that changes are reflected everywhere), and I give them their own layer for organization. However, sometimes I need to make a change or add a feature that requires a layer to be added or modified. Currently I have to go through each layout manually, and make the change. This is very tedious and boring. If I could create that layer at runtime (like the objects that populate it), I could avoid such mindless tasks.

    It would also be useful for games with level editors, as some levels may need more layers than others.

  • Do you use default platform behavior? Do you use the real x, y vel?

    Yes, that is the built in platform behavior. I just use some events to tweak some numbers (such as max speed, gravity, jump strength, and acceleration) under the right conditions.

    - Big Mario should slide off the box, not bounce against it when not breaking it.

    This is one of those things where the amount of effort spent trying to fix it would be better spent developing a custom platforming behavior where you can easily tweak the fine collision details, but at that point, I may as well not use Construct.

    - The star does not bounce against "brick" boxes. It needs it own family to collide against.

    I did kinda rush this one because I wanted to post the game, but getting it exactly right would require a lot more studying it, and I really wanted to get this done within a week.

    - Even the flag pole shares the same issues when hit with low x-vel.

    I'm not really sure what you are talking about here. I zero the player's X velocity and set their X position when they touch the flagpole anyway, so I'm not sure how a low X velocity could affect it. if you mean it gets activated before you actually touch the pole, that can be fixed with a simple X position compare.

    - Just watching the gombas for a while makes them stick together. I fixed this with a separate box for turning.

    Fixing this wouldn't be too hard if I could reliably reproduce it.

    - Contiguous walking to the left when big Mario on an edge with around 16 pixels of gap will kill Mario. Does Mario die when ofscreen?

    ???

    All I do is adjust the player X position if they are outside the bounds of the screen.

    Too bad that playing stuff in the wip "REALLY bothers" you. But maybe you got something out of it. Maybe a better feel for c2. Else you gonna waste a lot of weeks.

    Considering the goal here was to clone a Mario game, and the core aspect of Mario games is the platforming, I really think you should have spent more time on it. Getting other minor details wrong doesn't bug me nearly as much as getting the core gameplay wrong. I didn't even bother making anything else work until the platforming was just right, because it's so monumentally important in a Mario game.

    If you don't want to spend that much time on the platforming, perhaps you should try cloning a game with easier platform controls? Like Megaman? No X acceleration to worry about, no differing numbers based on how fast you are moving. All you need to work out is jumping higher by holding the jump button, and that's pretty easy once you know the trick (reduce player gravity immediately after jumping and while the jump button is still held). I don't know the exact mechanic Megaman uses to determine when the jump-hold effect should forcefully end, but Mario 1 ends it once you start falling, and Mario 3 ends it once your Y speed is high enough (above -2 pixels per frame, or -120 pixels per second). Figuring out how Megaman does it should be pretty easy with an emulator that lets you view the game RAM in real-time. Also stepping frame by frame. Lots of stepping frame by frame.

  • There are a lot of things that make this *not* feel like a Mario game, but most importantly are the platforming physics. It's so easy to get wrong and so many fan games do. This bothers me. Call it a pet peeve.

    Mario needs to accelerate to his max speed, not just get there instantly. His jump strength (and gravity) need to change depending on how fast he is moving. His jump needs to be higher if you hold down the jump button.

    To get a better feel for c2 I decided to remake level 1 from Super Mario Bros. as close to the original as possible.

    When I see something like the bolded part above, and the platforming controls aren't right, it REALLY bothers me. In fact, it bothered me so much, I spent the last week making this.

  • Problem Description

    If you try to preload a sound that does not exist, the "All Preloads Complete" condition will never become true

    This only happens when the project is exported for Node-Webkit. Previewing with Node-Webkit works fine.

    Attach a Capx

    https://dl.dropboxusercontent.com/u/207 ... _test.capx

    Description of Capx

    On start of layout, it preloads a sound that doesn't exist, and sets the text to "Preloading"

    When preloads are complete, it changes the text to "Preloads Complete"

    Steps to Reproduce Bug

    • Open capx.
    • Export for Node-Webkit
    • Run exported project.
    • Text will say "Preloading" instead of the expected "Preloads Complete"

    Observed Result

    Text says "Preloading"

    Expected Result

    Text says "Preloads Complete"

    Affected Browsers

    • Chrome: (NO)
    • FireFox: (NO)
    • Node-Webkit: (YES) (when exported)

    Operating System and Service Pack

    Windows 7 Home SP1

    Construct 2 Version ID

    Release 177 (64-bit)

  • The very last event in your project is creating an infinite recursion. Whenever an AlertPointer object is created, you are asking Construct 2 to create another one (which runs the 'On Created' event again immediately, creating another object). This causes an endless series of function calls with no returns, until the call stack overflows.