Jump to content
  • Advertisement

Wyrframe

Member
  • Content count

    1343
  • Joined

  • Last visited

Community Reputation

2441 Excellent

About Wyrframe

  • Rank
    Contributor

Personal Information

  • Industry Role
    Programmer
  • Interests
    DevOps
    Programming

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Wyrframe

    Line drawing in fragment shader

    This is an aliasing problem. The issue is that the sampling is skipping the coordinate you are testing for. You'll also discover that when zooming in closer than 1:1, you'll have thicker grid lines than intended. Instead of testing for == 0, calculate the world-position stride from one screen pixel to the next, use floating-point modulo instead (the function that trims off the integer part and leaves the fractional part intact), and choose grid colour if the current world-space position is >= 0 and < that stride (instead of < 1, which you are effectively doing here). Remember to respect the device pixel aspect ratio as well, so that this will still work on devices with non-square pixels.
  2. That one's outside my realm of experience, sorry. My C++ development environment never gets more complex than a single Makefile and vim. If it was a Java program, I might be able to help you out there.
  3. Your Brain destructor needs to be virtual. I don't think that should be causing this issue, but it may not be helping if the issue is being caused by copying of Brains and Sprites by the Vectors which contain them. Beyond that, I can't see the issue either. You'll have to just run it in a debugger and see if you can spot when it goes wrong.
  4. 'k, seems like you're attaching the control binding script to the right sprite. Time to crack open a debugger and confirm that the guts of each Sprite are what you expect them to be. I'm guessing something's going wrong with the private implementation management. Try instantiating your sprites in a different order, and seeing if that gives different results; that would suggest there is some data sharing going on which you're not expecting.
  5. I think there's some code missing. I can't see where Sprite::Move is called, nor where Input::GetKeyDown is called. The problem looks like it is wherever those two get tied together; I'm betting you're calling Move on the last Sprite created, not the designated Player sprite.
  6. Wyrframe

    GLSL: 9-slicing

    http://lmgtfy.com/?q=glsl+mix tl:dr; mix(a,b,q), given arbitrary values A,B, and a value from 0..1 Q, returns the value Q% of the way from A to B. I use it there to re-map a 0,1 range (the requested coordinate within the subsprite, the output of your original code) to the range within the texture (the bounding coordinates of the subsprite). Were you setting subsprite to (to extract subsprite #0 from the 4-subsprite texture map shown in your latest update) the vec4 value [0,0, texWidth/5, texHeight/2]? That's what passing the subsprite to use as a shading parameter (a uniform if you're drawing all boxes of one layer and type in one primitives call, or a varying if you want to draw a different box with each pair of triangles) is meant to do. You calculate the bounds once (or at most, once per draw call) in your program, and pass them into your shader as a uniform.
  7. Wyrframe

    GLSL: 9-slicing

    You just need to replace your hard-coded 0s and 1s with subspriteX/Y and subspriteW/H. uniform vec4 subsprite; // [0,1] aka x,y are top-left, [2,3] aka z,w are bottom-right. // all your code except main... vec2 subspriteMap(vec2 inner) { return mix(subsprite.xy, subsprite.zw, inner.xy); } void main(void) { vec2 newUV = subspriteMap(vec2(processAxis(...), processAxis(...))); gl_FragColor = texture2D(tex, newUV); } Untested, quickly banged together. But should do the trick.
  8. Right, I keep forgetting they were improved to the point of actually being useful in 5.2. Fair dues, but due to the way Lua is written, it's easy to accidentally create a global that you meant to be a local temporary (by forgetting to pre-declare it as `local ...`). You may want to use an Environment setup not to capture and preserve globals, but to log warnings whenever an unexpected global is accidentally created.
  9. It's brittle, but if you're the only person who'll be maintaining quests like this, documentation should get you over that hurdle. The problems are going to come in if two quests both accidentally assign different values to a global variable in common between them. Among other things, you probably want to introduce some data hygiene, which is going to be particularly necessary for serialization (read: save/load).
  10. Just realized what you actually probably meant. You want to load a script file, and populate a table with the functions that script file "declares"? This isn't possible the way Lua works, without some knowledge about how the script file is structured. Any fragment of source (be it a single string or a whole text file which to the lua parser is functionally a single string) gets compiled to, itself, be a function. When executed, all the top-level declarations in the source file get executed. So in your source file, each "function X() end" declaration is equivalent to "X = function() end", that is to say, assigning to the global variable "X". Identifying changes made to the global table is not an entirely solvable problem within the confines of Lua. But what you can do is what I and havsmontret suggested; have the script file itself return a table at the end; that will be the return value of doFile or what have you, and you can use that as the module the script file is supposed to implement.
  11. function makeFunctor(params) local table = { } function table.method1(params) ... end function table.method2(params) ... end return table end Or like this. Read up on https://www.lua.org/manual/5.1/manual.html#2.5.9 . Also, what is your use case, because there may be a better way to do it both visually and structurally?
  12. Instead of allowing the player to build arbitrarily thick walls of any sort, why not give them a different means of increasing the strength of walls? For example, allow each wall tile to connect to at most two other walls. That will allow only ribbons of wall, or air-gapped layered walls. Then, to discourage the player from making successive layers of wall, give them an economic reason to upgrade existing walls instead; let them triple the max HP of a wall by reinforcing it, at a resource cost of only an additional 1x or 1.5x of the base wall cost. Have the player focus on infrastructure over layers. Give walls an upkeep cost, so that a worker or whatever must come by and repair the wall periodically, even if this is semi-automated, even if the wall is not damaged, to keep it from losing max HP over time. This forces the player to reduce their total amount of walls used, or else pay ever-increasing amounts of workers and wall upkeep costs. Waive this cost if the wall has a manned "tower" or "parapet" attached within 3-5 wall sections in either direction, to give them a reason to build real defensive structures on the wall, and not just use it to dam up areas. Finally, give the player a reason to protect their walls. Have each 1x1 wall section, when destroyed, collapse into "ruined walls", which take up a 5x5 area and cannot be built on nor can other walls in that area be repaired until the "ruin" is cleaned up. To prevent the player using this defensively or as griefing, have it happen only if the wall is a member of a ribbon at least 5 walls sections long (two additional walls in each of two connected directions).
  13. Google'd "ios developer guide in-app purchases". First non-advertisement search result: https://developer.apple.com/in-app-purchase/ You're looking for the StoreKit API and toolbox. Note that a lot of the guide is made up of procedures you need to take while interacting with the App Store, so read it and re-read it before doing anything in XCode. It doesn't look like it was written for new programmers, though; looks like a lot of undocumented boilerplate Objective C and Swift code dotted throughout the articles.
  14. I mean a canvas created by the DOM and not attached to it for presentation on the page; not to the "headless" canvas feature for web workers, which is what that feature describes. For example, look to EaselJS's BitmapCache class. In particular, BitmapCache.js lines... * _updateSurface():442 (where it creates a canvas for this cache) * _drawToCache():518 (where it acquires a drawing context for that canvas and then draws to it) * draw():406 (where it copies its pre-rendered cached canvas' contents to another canvas' drawing context).
  15. Also, you can draw whatever on a canvas or an off-screen canvas surface, and then save a rectangle of it as a tile bitmap; you can then draw that bitmap with a very easy, fast operation as much as you need to. Look at how EaselJS implements "cached bitmaps", for example code.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!