Why is the button's code not running? My script for a slot machine isn't working. When the button in the Bilboard GUI is clicked, the below dosen't run. I am new to scripting and this is mostly based on wiki stack exchange Dev page info. local player game.Players.LocalPlayer local textLabel script.Parent local toggled false local button script.Parent textLabel.Text "Click to Play for 5 Cash!" slot1Combos "Bar", "Seven", "Seven", "Seven", "Cherry", "Cherry", "Cherry", "Cherry", "Orange", "Orange", "Orange", "Orange", "Orange", "Lemon", "Lemon", "Lemon", "Lemon", "Lemon", "Banana", "Banana", "Banana", "Banana", "Banana" slot2Combos "Bar", "Seven", "Cherry", "Cherry", "Cherry", "Orange", "Orange", "Orange", "Orange", "Orange","Orange","Lemon", "Lemon", "Lemon", "Lemon", "Lemon", "Lemon", "Banana", "Banana", "Banana", "Banana", "Banana", "Banana" slot3Combos "Bar", "Seven", "Cherry", "Cherry", "Cherry", "Orange", "Orange", "Orange", "Orange", "Orange","Orange","Lemon", "Lemon", "Lemon", "Lemon", "Lemon", "Lemon", "Banana", "Banana", "Banana", "Banana", "Banana", "Banana" local function onButtonActivated() if toggled false then toggled true x math.random(1,23) y math.random(1,23) z math.random(1,23) g false player.leaderstats currencyName .Value player.leaderstats currencyName .Value 5 if slot1Combos math.floor(x) "Bar" and slot2Combos math.floor(y) "Bar" and slot3Combos math.floor(z) "Bar" then player.leaderstats currencyName .Value player.leaderstats currencyName .Value 60 textLabel.Text "You Got 3 Bars. You won 60 cash" wait(5) textLabel.Text "Click to Play for 5 Cash!" elseif slot1Combos math.floor(x) "Seven" and slot2Combos math.floor(y) "Seven" and slot3Combos math.floor(z) slot2Combos math.floor(y) then player.leaderstats currencyName .Value player.leaderstats currencyName .Value 40 textLabel.Text "You Got 3 Sevens. You won 40 cash" wait(5) textLabel.Text "Click to Play for 5 Cash!" elseif slot1Combos math.floor(x) slot2Combos math.floor(y) and slot3Combos math.floor(z) slot2Combos math.floor(y) then player.leaderstats currencyName .Value player.leaderstats currencyName .Value 10 textLabel.Text "You Got 3 of a Kind. You won 10 cash" wait(5) textLabel.Text "Click to Play for 5 Cash!" elseif slot1Combos math.floor(x) "Cherry" and slot2Combos math.floor(y) "Cherry" and slot3Combos math.floor(z) "Cherry" then player.leaderstats currencyName .Value player.leaderstats currencyName .Value 20 textLabel.Text "You Got 3 Cherries. You won 20 cash" wait(5) textLabel.Text "Click to Play for 5 Cash!" elseif slot1Combos math.floor(x) "Cherry" and slot2Combos math.floor(y) "Cherry" or slot3Combos math.floor(z) "Cherry" and slot1Combos math.floor(x) "Cherry" or slot2Combos math.floor(y) "Cherry" then player.leaderstats currencyName .Value player.leaderstats currencyName .Value 3 textLabel.Text "You Got 2 Cherries. You won 3 cash" wait(5) textLabel.Text "Click to Play for 5 Cash!" elseif slot1Combos math.floor(x) "Cherry" or slot2Combos math.floor(y) "Cherry" or slot3Combos math.floor(y) "Cherry" then player.leaderstats currencyName .Value player.leaderstats currencyName .Value 3 textLabel.Text "You Got 1 Cherry. You won 3 cash" else textLabel.Text "Sorry, you didn't win" wait (5) textLabel.Text "Click to Play for 5 Cash!" end end button.Activated Connect(onButtonActivated) end) This is the explorer tree with the script highlighted


Verb Noun Parsers and Old School Visual Novels Hi I'm working on a simple old school visual novel engine in Lua. Basically I have most of the code set up besides one important feature. The Text Parser. Lets get into how words are generally structured. In the screenshot I input the command "my wish is for you to die" How would a human understand this? my noun object wish verb is connective equator similar to for connective object (for all objects of ..) you noun object to connective action similar to do die verb the computer can then parse this and understand it like this (pseudo example) my user you get current label() you "Lost Coatl" wish user command user command for all objects of "Lost Coatl" do die() end execute user command() What other ways do videogames use text parsers, what would be the simplest way for a newbie coder such as myself?


How to set speed based on screen size I am making a breakout clone for mobile and was wanting to make the ball speed to be related to the screen size. Larger screen would mean faster speed. Right now I have it set like so dirx math.random( 5,5) (maxx 320) diry math.random(3,7) (maxy 480) My reasoning for this is that 320x480 is iPhone resolution so I figured it would be a good base to start at. For the record, it actually runs pretty well on iPhone setting. Then for the actual movement I just add dir to the appropriate direction. ball.x ball.x dirx ball.y ball.y diry The problem is if I change to a device with a larger screen resolution, the ball is crazy fast and is very jumpy. Is some kind of formula that I can use to multiply to the random that will make the speed appear uniform across devices?


Determine required camera pitch yaw change based on mouse movement and roll? I'm sure this is going to be a pretty simple answer but I can't quite figure it out on my own. Each frame, I'm getting the mouse's distance from the center of the screen (left up is positive) and using it to change the camera's pitch and yaw. Then, I added camera roll. Now, if the camera is rolled 45 left, moving the mouse left needs to change both the pitch AND yaw. I know I need to use math.sin and math.cos but I can't get it to work quite right. Pitch and yaw are relative to the world, not the camera's view. AddYaw and AddPitch are hypothetical functions that apply world yaw pitch to the camera. So if the camera is rolled 90 degrees left (so right is world up), applying yaw will appear to make the camera pitch "up", which is still left according to the world. Due to the functions available to me through the game's API, I can't just apply camera relative pitch yaw, I'm restricted to world relative pitch yaw only. Basically, it boils down to applying some trigonometry to the mouse x y input to "rotate" the pitch and yaw values added to the camera. change.x distance mouse moved left right in this frame change.y distance mouse moved up down in this frame Fix me! local yawChange math.sin(rollInRads) change.x math.cos(rollInRads) change.y local pitchChange math.cos(rollInRads) change.y math.sin(rollInRads) change.x Apply pitch yaw changes to the camera Camera AddYaw(yawChange) Camera AddPitch(pitchChange) A few examples of what it needs to return. For clarity, yaw left positive, right negative, pitch up positive, down negative. Situation 1 No roll. Moving the mouse left applies positive yaw to the camera, moving the mouse up applies positive pitch. No conversion needed since camera yaw world yaw, camera pitch world pitch. Situation 2 Camera is rolled 90 degrees left. Now, positive camera yaw (left) is actually negative world pitch (down). Therefore, moving the mouse left needs to apply PITCH, not yaw. And moving the mouse up needs to apply YAW, not pitch. Situation 3 Camera is rolled 45 degrees left. Now, the camera world axes are a bit mixed. Moving the mouse left should apply equal amounts of negative pitch AND positive yaw so the camera's view moves left relative to its own view.


Love2d Failed to load tileset map I'm reading the Love2D Development book, which i think i will stop reading because is outdated and very instable, sometimes i got a lot of troubles. Backing to the question, i made a tileset map with Tiled and saved in .tmx with Base64 ( uncompressed ) then i used Advanced Tiled Loader and used the code from the book This is the main.lua file local loader require ("Advanced Tiled Loader master Loader") the path to our .tmx files and sprites loader.path "map " local map loader.load("tilemap.tmx") function love.load() love.graphics.setBackgroundColor(255, 153, 0) load the level and bind the variable map loader.path "map " local map loader.load("tilemap.tmx") end function love.draw() map draw() end When i tested the game, the result was this http i.imgur.com JM8EYrv.png The result was suposted to be like this http i.imgur.com W26XFjE.png So what it could be?


How do I get the player's position in Roblox Studio? In Roblox Studio, I have this code in a script file while true do wait(0.01) local PlayersService game GetService("Players") local players PlayersService GetPlayers() for i, player in pairs(players) do print(player.Name) end end This successfully prints the player's name many times per second. However, I would like to know how I can get other properties, such as the player's position. player.Position doesn't work, and I have no idea what options are available because autocomplete is not working when I type player.. What properties are available on player and how do I get the position?


Is it possible to generate Events and Hooks in Lua for any game without built in support? Does a game have to have built in functions to accept and run lua scripts, or can I design Events and Hooks using Lua on any game I please, akin to the days where C code could be used to hook into the WinAPI using dlls? The reason I ask is, I am trying to create a background application that will perform events and hooks on a particular game that does not currently support lua in game. Brief examples Events An action executed by the PLAYER is detected. For instance, hitting the Q key will normally make my character use an ability, but with my Lua script running in the background, will cause a sound to play on my computer (or something). Hooks An action within the GAME is detected. For instance, the game spawns an enemy every minute. When an enemy spawns, the script will detect this and perform an action, for instance playing a sound locally on the computer. I would like to do both, but I know for games like Garry's Mod, the game already has built in support for running lua scripts. Is there a way to do either events OR hooks using lua similarly to how C C can connect to a game using WinAPI dlls?


How to connect a GUI button to function? I am developing a new Roblox game where you can setup and control you're own virtual machine using SurfaceGUIs on a modeled screen. I am trying to make a confirmation GUI where if you click YES, then it starts the VM, and if you click NO, then it closes the GUI and doesn't start a VM. But when I click on NO, nothing happens! Here is my code local gui script.Parent.Parent local button script.Parent local function cancel() gui.Visible false end button.Activated Connect(cancel()) Please help! P.S The confirmation frame is in the ScreenGUI, the button is in the frame, and the LocalScript is in the button.


Lua Unknown error when typing something in Zerobrane studio IDE What is this weird error that I am getting when I typing something in the Zerobrane studio IDE? It crashes my IDE. But The game project compiles and runs fine. When I turn off "Autocomplete Identifiers" from Edit menu, then the error doesn't come up. Also, I searched entire google and facebook for some help or solution but no luck at all.


Pathfinder is making my NPC follow my oldest position only I am trying to make a maze horror game. I used an online template in the Roblox library as my enemy. I used pathfinder as you will see in the code below. It's finding me like it's supposed to, except it only goes for my LAST position. As you can see in the image below, it completely skipped me, went to my LAST position, then started chasing me. I don't know why it only goes for my last position, and not my current position. local PathFindingS game GetService( quot PathfindingService quot ) local humanoid script.Parent WaitForChild( quot Humanoid quot ) local rootPart script.Parent WaitForChild( quot HumanoidRootPart quot ) local Players game GetService( quot Players quot ) game.Workspace.Fruity.Humanoid.WalkSpeed 60 To calculate the path while wait() do for i, player in pairs(game.Players GetPlayers()) do local character game.Workspace WaitForChild(player.Name) local characterPos character.PrimaryPart.Position local path PathFindingS CreatePath() path ComputeAsync(rootPart.Position, characterPos) game.Workspace.Fruity.HumanoidRootPart SetNetworkOwner(nil) local waypoints path GetWaypoints() for i, waypoint in pairs(waypoints) do local part Instance.new( quot Part quot ) part.Shape quot Ball quot part.Material quot Neon quot part.Size Vector3.new(0.6,0.6,0.6) part.Position waypoint.Position Vector3.new(0,2,0) part.Anchored true part.CanCollide false part.Parent game.Workspace humanoid MoveTo(waypoint.Position) humanoid.MoveToFinished Wait() end end end


NLua How to implement Roblox like function security? Roblox uses Normal Identities, basicly they assign a lua block object to a certain number. They use 2 for Scripts and LocalScripts, which can only use non secured functions, while the command bar can access everything that is LocalUserSecurity and RobloxPlaceSecurity. How can I implement this type of Lua Security into NLua?


Got unexpected results from perlin noise. Wondering what it is doing? I was just messing around with perlin noise and got this. Wondering if anyone knows what it is or has seen it before. Here is the code(LUA with love2d engine) function love.load() love.window.setMode( 1920, 1080, fullscreen false ) Assuming you called the module perlin.lua newperlin require("perlin2") newperlin is a function that generates Perlin noise objects myperlin newperlin() 333 is seed myperlin newperlin(333) mapHeight 400 mapWidth 400 then, to create noise scale 0.007 map for x 0, mapWidth 1 do map x for y 0, mapHeight 1 do map x y 0 map x y map x y (myperlin noise(x scale, y scale) 1) 2.0 255.0 The following lines change it from a cloud to a weird image smin 0 smax 255 map x y math.floor(( map x y ( 0.5) ) 255 ( 0.5 ( 0.5) ) 0) end end end function love.draw() for x 0, mapWidth 1 do for y 0, mapHeight 1 do love.graphics.setColor(map x y , map x y , map x y , 255) love.graphics.point(x,y) end end end function love.update() end function love.keyreleased(key) if key "escape" then love.event.quit() end end and here is perlin.lua


Lua script for World of Warcraft Get Quest Info I'm looking to make a very simple addon or even a macro where I can enter a quest ID and get the quest completion status. As it is, I know I can use IsQuestFlaggedCompleted to get the quest status, but I wanted to also get the name of the quest so the return in the chat log will show something a little more understandable. For example Enter questDone 43502 instead of just 43502 true as the output, I want it to look like A Change of Seasons Quest Completed. I see a function C TaskQuest.GetQuestInfoByQuestID that's supposed to return the quest's title, but it doesn't seem to work as expected. It always seems to return nil for the quest name...


How to make the character dash forward in Roblox? In my game I want to make a skill in a tool to dash forward for a specific range and if the character came in contact with a humanoid during the dash, it stops right on contact and stops the other humanoid from moving temporarly too and deal damage I don't know what functions should i do and where to look for them... i figured how to use onActivate and getting the mouse through Equipped Appritiate any help and guidance


When PlayerRemoving event is fired, for loop does not work properly while I was implementing the Backback save feature in my Roblox Game (using game.Players.PlayerRemoving Connect(), I found that when I used a loop of any form (for, while,etc.), it would not run correctly. Here is a test program which I wrote to observe this issue game.Players.PlayerRemoving Connect(function(player) local testList "Hello", ",", "world" for i 1,3,1 do print(testList i ) end end) However, when this code is ran, all I see in the output window is Hello And nothing else. This issue is causing a lot of issues with the rest of the code, can somebody please help? It would be very useful!


Sprite batching and dealing with isometric depth sorting So I'm using Love2D which uses SDL2 as far as I'm aware and I have a question about texture atlases amp spritebatching. I have an isometric chunk, with 2 layers, terrain and objects (trees, buildings, units). The terrain is not animated and the tiles are 32x16, they fit perfectly even in a 1028x1028 texture atlas. However the object spritebatch layer is a different thing. I have trees, that are animated and each frame uses up to 200x200 space in the atlas. You can see the problem. Now, I think I can fit all of it in a 8192x8192 texture and this is OK for my GPU, which is entry level (GT 720). It gets stored in the VRAM. So I conducted some test and imported a 10k x 10k image, the GPU could not handle it, and it was loaded onto the RAM. What exactly happens here? How much is the performance loss, I'm about to test, but is this going to cause any incompatibility problems? Other than the 300MB RAM usage instead of VRAM. Now, you might state the obvious, "Why not use 2 or more texture atlases?". I don't know if I'm doing things wrong, but I want to use sprite batches for the object layer, and the way I'm drawing it is this function update objects() object batch clear() for i 0,chunk width 1,1 do for o 0,chunk height 1,1 do object batch add( tile quads objects chunk i o , (i o) tile width 0.5, (i o) tile height 0.5 tile offset objects chunk i o ) end end object batch flush() end In order to deal with the depth issue that isometric games have, I simply draw furthest to closest. As far as I'm aware, sprite batches can only use 1 texture atlas, and I confirmed that by tests. Of course, there's a draw call that draws the sprite batch. I'm ok with several draw calls (units, buildings, environment in 3 separate batches for example), but I don't see how I will deal with the depth issue if I do go that way. (not OpenGL as I previously stated) Any ideas?


Unwanted line between chunks in heightmap infinite terrain I can't figure out what is causing the line between my two chunks. They are completely aligned. It must be something to do with the algorithm. I am using lua with the love2d game engine. Here is a pic Here is the code seed 257 local canvas love.graphics.newCanvas() function Interpolate(a, b, x) ft x 3.1415927 f (1 math.cos(ft)) 0.5 return a (1 f) b f end function Noise(x, y) n x y seed n bit.bxor((bit.lshift(n,13)),n) return ( 1.0 ( bit.band((n (n n 15731 789221) 1376312589), 0x7fffffff) 1073741824.0)) end function SmoothedNoise1(x, y) corners ( Noise(x 1, y 1) Noise(x 1, y 1) Noise(x 1, y 1) Noise(x 1, y 1) ) 16 sides ( Noise(x 1, y) Noise(x 1, y) Noise(x, y 1) Noise(x, y 1) ) 8 center Noise(x, y) 4 return corners sides center end function InterpolatedNoise 1(x, y) integer X, fractional X math.modf(x) integer Y, fractional Y math.modf(y) v1 SmoothedNoise1(integer X, integer Y) v2 SmoothedNoise1(integer X 1, integer Y) v3 SmoothedNoise1(integer X, integer Y 1) v4 SmoothedNoise1(integer X 1, integer Y 1) i1 Interpolate(v1 , v2 , fractional X) i2 Interpolate(v3 , v4 , fractional X) return Interpolate(i1 , i2 , fractional Y) end function getExampleMap() mapWidth 400 mapHeight 400 mapMin InterpolatedNoise 1(0, 0) mapMax mapMin map amp 128 freq 32 octaves 6 for x 0, mapWidth 1 do map x for y 0, mapHeight 1 do map x y 0 for i 1, octaves do map x y map x y getNoiseValue(x, y, freq i, amp i) end mapMin math.min(mapMin, map x y ) mapMax math.max(mapMax, map x y ) end end scale the values between 0 and 255 for rendering in grey scale. mapMultiplier 255 (mapMax mapMin) for x 0, mapWidth 1 do for y 0, mapHeight 1 do map x y map x y mapMultiplier end end end function getExampleMap2() mapWidth 400 mapHeight 400 mapMin InterpolatedNoise 1(0, 0) mapMax mapMin map2 amp 128 freq 32 octaves 6 for x 400, (mapWidth 400) do map2 x for y 0, mapHeight 1 do map2 x y 0 for i 1, octaves do map2 x y map2 x y getNoiseValue(x, y, freq i, amp i) end mapMin math.min(mapMin, map2 x y ) mapMax math.max(mapMax, map2 x y ) end end scale the values between 0 and 255 for rendering in grey scale. mapMultiplier 255 (mapMax mapMin) for x 400, (mapWidth 400) do for y 0, mapHeight 1 do map2 x y map2 x y mapMultiplier end end end function getNoiseValue(x, y, freq, amp) return InterpolatedNoise 1(x freq, y freq) amp end function love.load() love.window.setMode( 1920, 1080, fullscreen false ) getExampleMap() getExampleMap2() end function love.draw() for x 0, mapWidth 1 do for y 0, mapHeight 1 do love.graphics.setColor(map x y , map x y , map x y , 255) love.graphics.point(x,y) end end for x 400, (mapWidth 400) do for y 0, mapHeight 1 do love.graphics.setColor(map2 x y , map2 x y , map2 x y , 255) love.graphics.point(x,y) end end end function love.update() end function love.keyreleased(key) if key "escape" then love.event.quit() end end If I use seed 345 there is no line.


Game state management (Game, Menu, Titlescreen, etc) Basically, in every single game I've made so far, I always have a variable like "current state", which can be "game", "titlescreen", "gameoverscreen", etc. And then on my Update function I have a huge if current state "game" game stuf ... else if current state "titlescreen" ... However, I don't feel like this is a professional clean way of handling states. Any ideas on how to do this in a better way? Or is this the standard way?


Love2D how to zoom out map? I've set up a basic map with Tiled, imported it with STI library (https github.com karai17 Simple Tiled Implementation) and everything looks in place. How can i get a zoom out feature now? I can kinda zoom in using scalex and scaley and i tried the same procedure to zoom out. However, if i set i.e. scalex 0.5, scaley 0.5 the map actually scales in size but it only fit 1 4 the screen size, and the remaining 3 4 are just black space.


Verb Noun Parsers and Old School Visual Novels Hi I'm working on a simple old school visual novel engine in Lua. Basically I have most of the code set up besides one important feature. The Text Parser. Lets get into how words are generally structured. In the screenshot I input the command "my wish is for you to die" How would a human understand this? my noun object wish verb is connective equator similar to for connective object (for all objects of ..) you noun object to connective action similar to do die verb the computer can then parse this and understand it like this (pseudo example) my user you get current label() you "Lost Coatl" wish user command user command for all objects of "Lost Coatl" do die() end execute user command() What other ways do videogames use text parsers, what would be the simplest way for a newbie coder such as myself?


Why can t this boolean stop the sound from playing 60 times a second? The code local dontPlayMoreThanOnceDammit false function Behavior Awake() local sound CraftStudio.FindAsset( quot motorbuson1 quot ) self.mySoundInstance sound CreateInstance() self.mySoundVolume 1.0 self.mySoundInstance SetLoop( true ) self.mySoundInstance SetVolume( 1.0 ) end function Behavior Update() if dontPlayMoreThanOnceDammit false and CraftStudio.Input.WasButtonJustPressed( quot on quot ) then self.mySoundVolume 1.0 self.mySoundInstance Play() dontPlayMoreThanOnceDammit true end if CraftStudio.Input.IsButtonDown( quot off quot ) then self.mySoundInstance Stop() dontPlayMoreThanOnceDammit false end end Error it gives


How to set speed based on screen size I am making a breakout clone for mobile and was wanting to make the ball speed to be related to the screen size. Larger screen would mean faster speed. Right now I have it set like so dirx math.random( 5,5) (maxx 320) diry math.random(3,7) (maxy 480) My reasoning for this is that 320x480 is iPhone resolution so I figured it would be a good base to start at. For the record, it actually runs pretty well on iPhone setting. Then for the actual movement I just add dir to the appropriate direction. ball.x ball.x dirx ball.y ball.y diry The problem is if I change to a device with a larger screen resolution, the ball is crazy fast and is very jumpy. Is some kind of formula that I can use to multiply to the random that will make the speed appear uniform across devices?


file write restarts Corona app I am attempting to implement an auto save feature into a mobile game. I have the following code writing to the save file function saveFunc(input) local saveData input local file io.open( "saveFile.txt", "w" ) for i,val in ipairs(saveTable) do saveData saveData.." n"..val end file write( saveData ) io.close( file ) end This writes to the file correctly. The problem is that after the function finishes, the whole app restarts. Watching the output console, it re prints the "Copyright (C)..." as if I had Relaunched the app. I know it is this specific function because if I comment out the call for this function the game continues as normal. I also tried commenting out the io.close(file) but the program still restarted. How can I write to a file and not restart the app?


Mafia kill algorithm I'm making an Omerta clone mafia game and trying to work out a kill algorithm. Just a basic formula to decide how many bullets player A needs to kill player B. The inputs are players rank (out of 10), and a players kill skill (out of 100). The algorithm needs to return how many bullets are needed for that player to win. If you're shooting someone a higher rank, or higher kill skill, it should require more bullets. Anyone ever done anything like this and can offer some tips? Example chart


algorithm for combining smaller tiles to balance the bigger ones I have a field of tiles basically each tile is a country that has some kind of sovereign. The tiles countries have different weight. For now I use some numerical value but in the future the weight will depend on tile size, produced resources and so on. So I want for those countries to make alliances if their sole weight is much lower or at least lower than a certain threshold than the weight of the neighborhood tile (each sovereign is basically a primitive AI at that stage that is able to make decision to create the alliance). Here is couple of scenarios Here are the examples for bigger maps with possible alliances So my question is is there some kind of algorithm that allows to achieve that or I have to create it myself or use training sets for AI to gain the ability to form alliances?


Need help with algorithm for generating connected bricks in Pick A Brick clone I want to make a clone of an Amiga 500 game, Pick A Brick, a 2D game where the goal is to clear a table of bricks by matching them up, following certain rules. I am getting nowhere when it comes to the algorithm for generating the layout of the bricks. I have added the rules of the game (as I remember them) below. The player wins the game by clearing all tiles before the time runs out. Tiles are cleared by clicking on a pair of them and if the following is true The tiles must be of the same type (there is only one pair of each type). There is a clear path between them (more on path in the points below). The path from a tile must always start towards an (clear) edge of the screen. The path between the tiles must be u shaped. (edit) NOTE In the video the path is not always the u shaped. I do not recall if the path shown is just a shortcut or not, but regardless, in my version I do not want to allow removing tiles "from inside out". I have done some manual testing prototyping using both outside in and inside out approaches, with variations on both. So far, nothing I have come up with has really come close. I kind of dislike asking a question like this since it is so specific, probably not of general interest and may take up more than a little time for anyone interested in helping out. That being said, some people enjoy coming up with algorithms and "solving stuff", and the community may learn something from the answer, so, a post it is. (edit) Clarification. The algorithm must provide a solvable solution.


Generate 2D Triangular Mesh from Vertices on a Map Given a map of vertices (x1,y1), (x2,y2), ... (xn,yn) , how can I generate a 2D triangular mesh covering all vertices, and where the area of all triangles completely covers the map? The triangular areas may fully enclose other triangular areas, but no two triangles may intersect.


Split a grid into shapes that can be moved back from 4 directions Basically I have 4 grids Left, Right, Top, Bottom. Player can choose each of them and move all the blocks on that grid to the Middle grid to fulfill it, like tetris from 4 directions 0 0 0 0 0 0 (0 is empty, 1 is generated block) 0 0 1 Bottom gt Mid Right gt Mid Top gt Mid Left gt Mid 0 0 0 0 0 0 0 1 0 1 0 0 1 1 0 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 1 1 1 1 1 1 gt Win! Generate 1 0 0 0 0 0 0 1 1 0 0 0 0 1 1 0 1 1 1 1 1 another game. 0 0 0 1 0 0 1 0 0 The point here is to make sure there is at least 1 way for player to combine all 4 grids. What I've tried so far is generate the right order first (Left Right Top....), then generate all the blocks 1 by 1. When a block is generated, i perfomn a check with the generated order (move all the blocks in Left to Mid, then Right then Top...) to see if its still working, the code is similar to this (left gt right, top gt right gt botttom gt left, top... it doesn't have to be all 4 directions) Random the right direction order. Generate all possible coordinates from all the directions from the path above. Initialize an empty list to store all chosen coordinates. While(!(Generate enough x x block)) Get one coordinate from all possible coordinates if (Perform a check with the right order and the chosen list) Add it into the chosen list. The problem here is a block can be wrong at this point, but it can become right when another block is generated 0 0 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 At this point the logic is wrong But if I add 1 more block to the with Top gt Left gt Bottom order. top grid, it'll become right. There is no way to check if the each block is right or wrong without re calculate all the generated blocks logic So i want to ask if there a better way, algorithm to do it.


How should a circuit or power system (like redstone in Minecraft) be implemented I want to implement a power system like the redstone system in minecraft. I have n power sources and m cables. If I disconnect the power source or a cable the circuit should turn off. How do I avoid circles? If each cable with the status "on" powers the nearby cables I can create infinite circles where there is no power source involved (see image). Plus site is that it runs in T m I could send power burst through the graph starting at every power source and in each update call I turn every cable off. Problem is it runs in T n m. Is there a best practice? In Minecraft the redstone system was very slow so I think I overlooked something. EDIT The system should work without a distance based decay.


Why can't my A implementation find a path out of an open room? I tried to follow this article with the following example, but in my attempts it always ends up with a dead end. If we take G being 10 in a straight line or 14 in a diagonal, and H the distance in horizontal or vertical to the target point, then we restart this search for every tile that is the nearest one to the target point. I have this result if we take one or the other direction with 54, it ends up with a dead end. For example, if we go up from 40 to 54, then to 60, when we restart the search with G and H, it ends up with "4" (second shema) and comes back in a dead end Why does this happen and how can I solve it? I also looked at the wiki, but I did not understand the system with the colors and the code shown.


AI for solving a Match 3 game Is there a known good way to have a "computer" opponent play a Match 3 game? It doesn't have to be fancy, or even considered fair. If the AI always takes the best move on the board that would be OK with me. Note that a valid move is one that doesn't make a match. Edit What I am currently doing is a brute force approach. I look at every tile on the board, and see what the best move that tile can do. I add it to a collection and give it a score (based on how many it will match 3 or 4). Once I have traversed the entire board I use the move with the best score. In the event of a tie I pick one. If a 5 match combo is found I short circuit out to that one. 5 is the highest combo you can get) I may not be able to improve it, but it feels like this should have been solved already.


Codify user progress I want to generate a string code for the user that represents his progress in the game (so he can load this state somewhere else). I don't want him to be able to guess the system and thus load a state which he hasn't yet achieved. The following variables are involved A number X between 1 30 representing the highest level he unlocked. For each level lower than X a boolean representing whether he made the level on hard or not. For each secret object he could have found (also roughly 30) another boolean. My idea was to just build a binary number from all these but that's just way too easy for the user to hack. If he beats level 1 and then saves, he will see his code being something like 0x1, while having bet level 10 will be something like 0x200.


How can I detect connected (but logically distinct) bodies of water in a 2D map? I have a 2D hexagonal grid map. Each hex cell has a height value used to determine if it's water or ocean. I'm trying to think of a good way to determine and label bodies of water. Oceans and inland seas are easy (using a flood fill algorithm). But what about bodies of water like the Mediterranean? Bodies of water that are attached to larger ones (where "seas" and "gulfs" differ only by the size of the opening)? Here's an example of what I'm trying to detect (the blue body of water in the middle of the image, which should be labelled differently from the larger body of ocean on the left, despite being technically connected) Any ideas?


Algorithm Logic of identifying a circle in Go game I'm trying to create a 2 players Go like game. Unfortunately I can't get the capturing system to act correctly. At the moment the system is half done, however I cannot think of a perfect way for it to recognize a circle correctly. This is the logic that I'm planning at the moment (let say it's currently White's turn) 1.Using the newest placed piece as the starting point, run a flood fill (Up, Down, Left, Right) code to find all the affected nodes Black piece, and place them in a "suspects list". 2.Using the suspects list, find any White piece that is near them (Up, Down, Left, Right, UpLeft, UpRight, DownLeft, DownRight). Adds those pieces into a "circle candidate list". 3.Run through the circle candidate list and remove any piece that doesn't connect to at least 2 other candidates. Keep doing this until all candidate are connected to at least 2 other candidates or the number of candidates are less than 4 (which won't be possible to make a circle). 4.Using a recursive method checks whether we can make a circle using all the candidates. The last piece must be connected to the first one. 5.If a circle is identified, get all the nodes that are between the candidates, first checks from top to down then left to right. Records all the nodes that were identified in both checks as dead zones. Kill any Black piece inside the dead zone and any Black piece that is place inside there after this will automatically die. Here's where the problem is, I noticed that 3 pieces that are next to each other will still be connected to 2 other piece. Which means the system will still see them as a legitimate candidate even if they aren't part of a circle. And secondly the way I use to check if there is a circle can easily fail if there are more than necessary pieces to make the circle since it could turn the wrong way and then unable to get back to the starting point. I've been struggling with this capturing process for a week now, and tested a number of different ways. All of it will have a problem in certain scenario which resulted in a bug (either they're not capturing piece that should be captured, or capturing piece that should not be captured). So any help are greatly appreciated. Thank you.


Procedural river or road generation for infinite terrain I should say paths, not roads as I'm thinking more medieval like. Also, not looking for realism. The answer I'm looking for will be to fit into the mold I describe rather than realism. I am looking for a method to generate procedural roads rivers in a curvy sort of fashion, but I'm wanting to do so for a infinite terrain type system. Just like how perlin noise generates blobs, I'm wanting to generate random length line segments (possibly infinite length). I'm aware of strategies like the suggested answer found here, however it relies on a specified start and end point to work, I don't have a specified start and end point. I'd like to be able to simply call a function using arbitrary coordinates and have it return whether the specific coordinates are part of the river road. I am not wanting to require terrain to be generated in advance. That includes a heightmap (like used for rainfall simulations or similar). I would also not want to require a start end point. Is there such an algorithm or tweak to a noise algorithm someone might know of to accomplish what I'm trying to explain? The closest I've came to so far is multi ridged fractals, if I'm using the name properly. I'm just taking the absolute value of value noise (assuming it is scaled to 1 to 1) and setting a threshold. My primary issue with this is the lines overlap way too often, are mostly circular, sometimes converge to form large lakes which is neat but undesired, and often times the thickness of the lines vary too much. Here's a picture of what I have so far in 2D, but at a very high frequency to show more detail


3D pathing finding with flying Does anyone know of a (free or paid) solution that enables 3D path finding? Basically something like CalculateRoute(input geometry, start pos, end pos, variance) I found a good paper on the topic, but I haven't found any solutions via Google or even searching sites like odesk, etc... I know recast detour is great for ground navigation, but I can't find anything that involves flying 3D space. Any suggestions would be great to existing solutions.


How to create a random, warped 2D grid? How do you create a random grid where the lines aren't orthogonal (and cells aren't a perfect square), but are warped? Here's an example of what I mean (Credit screenshot taken from a video by Silvarret about the game Townscaper.) Lines curve. Sometimes many cells come together in a single point. Yet, it still looks like a grid and the cells are clearly visible and roughly equal in size and shape. I have absolutely no clue how to go about something like this. How is this achieved? Is there an algorithm for this? How would you detect the cell over which the mouse hovers?


Logic behind a bejeweled like game In a prototype I am doing, there is a minigame similar to bejeweled. Using a grid that is a 2d array (int , ) how can I go about know when the user formed a match? I only care about horizontally and vertically. Off the top of my head I was thinking I would just look each direction. Something like int item grid x,y if(grid x 1,y item) int step x int matches 2 while(grid step 1,y item) step matches if(matches gt 2) remove all matching items else if(grid x 1,y item .... else if(grid x,y 1 item) ... else if(grid x,y 1 item) ... It seems like there should be a better way. Is there?


How would one determine the position of a participant in a racing game? Now, for the record, I'm currently not implementing any racing game whatsoever, but this problem just popped into my mind and now I'm curious. So how would one go about finding out which participant of a race is currently the first one? It can't be something trivial like just sorting by distance to the finish line because that would be highly inaccurate on most courses. I've thought about doing something like separating the route into straight segments, each of which has a direction vector. The game would then check for when someone outruns somebody else by projecting their positions onto that vector and checking which one is ahead. If the position has changed, the game would increment decrement them appropriately. But that does seem a little too complicated. Does anybody know of any established methods or has any experience in implementing some?


Why is my bullet disappearing after I release the shoot button? I'm making a game using DirectXTK for my university project. When I press space bullet moves forward like I wanted, but when I let go it stops my bullet from moving. How do I keep the bullet moving when space was pressed? void update shooting if (kb.Space) Shoot(true) else Shoot(false) void Render() if (draw) for (int i 0 i lt 10 i ) m projectile i gt Draw(m bullet i , m view, m proj, Colors Red) bool shoot(bool test) shoot test draw true bool isShot false if (!shoot) for (int i 0 i lt 10 i ) m bullet i Matrix CreateRotationY(m ship. 42) m ship else m bullet 0 Matrix CreateTranslation( Vector3 Forward float(1)) Matrix CreateRotationY(0.f) m bullet 0 m bullet Matrix CreateTranslation( Vector3 Forward) return draw


How to make score points based on time So the idea is simple. a) Players why finish the level faster, should get higher score. b) The levels (1 to N) where every next becomes more difficult should impact the score. So it's kind of mix of quot time to complete quot and quot level number quot . If would know the fastest possible time the user can complete the level, I would do the fallowing a) If player completes the level in fastest time, it gets max score 100. b) If it takes, for example, twice as long I divide by 2 and get 50. c) Then I multiple by the level number assuming that every next level is twice as difficult. Example Player completes level N two times slower than fastest time, so Score 100 2 N 50N But the problem is that I can't really figure out the this fastest time for each level, because my game is a complex randomized 4d maze and I have no idea how fast a pro gamer can complete it to define the max score. And without that I have no idea how to calculate the score. This question is all about quot Can we figure out the score without knowing the fastest time quot Any help appreciated.


What is the simplest method to generate smooth terrain for a 2d game? What is the simplest method to generate smooth terrain for a 2d game like "Moon Buggy" or "Route 960"? I got an answer at stackoverflow.com about generate an array of random heights and blur them later. Yes, it's quite okay. But it would be better to give some points, and get a smooth curve.


Integrating specular, diffuse reflection and refraction I am implementing an MLT bidirectional path tracer. I have a problem integrating diffuse, specular reflection and refraction. 1) The first problem is diffuse and specular reflection. Diffuse reflection is done by sampling ray in a hemishere. But specular reflection is done by finding the ray that have an angle to the normal equal to the incident ray with the normal. However, an object can have both diffuse and specular reflection. When to use specular reflection or diffuse reflection for a ray? 2) Same as the first question but this time integrating reflection with refraction. I've seen a few research papers and websites online where the scene have specular, diffuse reflection and refraction, but they have no tutorial on how to do this.


Checking whether moving object has reached target position So I have a fast moving object in my game, let's say a bullet. At each iteration of the main loop I update the object's position based on the delta time value dt and draw it at the new position. I also check whether the object's new position is close to a target position. In that case the object will be removed S.... ... .... .... ...... ... .... .... ... ..T.. X The object starts from location S, moving towards target position T. Each dot . represents one ms time. The vertical bars represent a game loop iteration, in which I check whether the object has reached its target destination. At X the object will be removed. Since these checks (ie. game loop iterations) might take place before or after the 100 exact target position (even if only a few pixels off), I perform this check with a distance between a line segment from the last position to the current position, and whether the target position is on that line. This approach works well. There is one issue though Since the check in which I recognize that the target has been reached happens after the real position of the target, the object moves a little bit further than desired. That's becoming more severe when the object is moving very fast. Now my question Is there kind of a "best practice" how to deal with this issue? I assume this is a common problem in game development. PS The only solution I could think of is to re position the object to the real target position as soon as the check succeeds. However, that can look a bit like a "jump" back, which does not look great.


Algorithm to select all cells inside rooms regions I have a 2d game map consisting of several 'rooms' For example, here is a 2D map grid (Brown cells wall tiles) If I click on a tile (that isn't brown), I would like to obtain an array of all the cells in the region that I clicked. (If the region is bounded by brown tiles, otherwise do nothing) For example, there are two regions in the image above, both colored in grey. If I clicked cell (4,4) I would get a 4x5 array of cells starting at (3,3). Does anyone know a good performance efficient algorithm for this? I need to account for non square rooms ideally.


How can I locate empty space next to polygon regions? Let's say I have the following area in a top down map The circle is the player, the black square is an obstacle, and the grey polygons with red borders are walk able areas that will be used as a navigation mesh for enemies. Obstacles and grey polygons are always convex. The grey regions were defined using an algorithm when the world was generated at runtime. Notice the little white column. I need to figure out where any empty space like this is, if at all, after the algorithm builds the grey regions, so that I can fill the space with another region. Basically what I'm hoping for is an algorithm that can detect empty space next to a polygon.


Object detection in bitmap JavaScript canvas I want to detect clicks on canvas elements which are drawn using paths. So far I have stored element paths in a JavaScript data structure and then check the coordinates of hits which match the element's coordinates. Rendering each element path and checking the hits would be inefficient when there are a lot of elements. I believe there must be an algorithm for this kind of coordinate search, can anyone help me with this?


How can I create a random "world" in a tile engine? I am designing a game that is working on a classic tile engine, but whose world is generated randomly. Are there existing games or algorithms that do this? The procedural generation algorithms I have found are never using a tile system... What would be the best way to generate a whole "world" using a tile system? I am not talking about mazes of blocks, but an overall "world map" thanks


Implementation of finding an index in a 1D array for a triangular grid Am using a while loop to find an index within a 1D array, is there an easier, less time consuming and or mathmatical way to find the index? Consider the next grid 4 o 3 o o 2 o o o 1 o o o o 0 o o o o o 0 1 2 3 4 To find an index in the triangular grid within a 1D array I have the next function int size 5 int getindex( int x, int y ) int columnCount size while( y gt 0 ) x columnCount return x The array (The numbers within the parenthesis are the coordinates and to simplify your view, in reality the (x,y) is in its whole the data) pointdata data 15 (0,0), (1,0), (2,0), (3,0), (4,0), (0,1), (1,1), (2,1), (3,1), (0,2), (1,2), (2,2), (0,3), (1,3), (0,4),


How to track and find entities within radius in realtime game? What is best approach to implement tracking in real time for, say, 1000 npcs? Every frame update simple a square grid (remove or insert into linked list) and every time check in square radius? I tried kd tree but its really bad in real time updates even with 100 entities I can't reach 10 FPS.


How would one determine the length of a path? I have a game that requires each player to move along one specified path. I draw the path using B zier curves. How can I determine the total real (not linear) length of the path and the distance that each player had made? (The distance between the start point and a specified point on the path.) UPDATE The path is represented in a Cartesian plane (2D).


Procedurally generating dungeons using predefined rooms Most attempts at procedurally generating dungeons I have stumbled upon do space out areas that will be rooms and connect them will corridors and hallways but what about instances where you have a collection of possible rooms in various dimensions and want to generate a dungeon that uses some of these specific rooms without those corridors and connections? To answer this question I found this particular video on the topic of generating levels in Path of Exile ( 5 20 7 20 about the dungeon part I am referring to) which left questions open on how to technically implement the algorithm described. In general I understand the idea but I am struggling to figure out how this would be translated into code (most efficiently) and therefore here are a few questions When he shows how the entire level is sliced up I could not come up with a graph that would allow to represent this structure. My naive approach would be to have the entire level consist of 1x1 rooms and arbitrarily merge nodes in the graph to form rooms of valid dimensions (valid there is a predefined room that can be inserted there later on). What would be a suggested approach to this? Coloring the rooms should be just assigning random distances (in a given interval) to edges of connected nodes and just applying Dijkstra to find the sequence of rooms from start to finish I presume? When he adds branching rooms I noticed that they do not allow another alternative path to the exit (which could be random of course) but how would one implement the branching? Just a recursive traversal with diminishing chances of continuing deeper into the graph? Description of the algorithm in the video Step 1. Place a start and end room arbitrarily into the level (presumably with a given minimum distance to prevent degenerate layouts) Step 2. Slice the entire level into areas that have exactly the sizes of your predefined rooms Step 3. Assign each room a random weighting distance which is depicted with colors in this example Step 4. Find a shortest path to get a nonlinear path from start to end Step 5. You have your basic layout with a single successful path in which you can place random rooms of corresponding sizes that have to be connected with appropriate doors Step 6. Finally, add some branching rooms


Can you use A to make a unit move nonspecifically? A is typically used to calculate the best way to move towards something, and it's quite flexible when it comes to threats, extra movement costs, and 'refuelling' on the way to something. However, if you designate only threats, perhaps with a main threat first and foremost, can you use it for "finding somewhere to go"? What about adding both threats, safety, resources and other such heuristic influencers to determine what a unit does when idle?


Checkers AI Algorithm I am making an AI for my checkers game and I'm trying to make it as hard as possible. Here is the current criteria for a move on the hardest difficulty 1 Look For A Block This is when a piece is being threatened and another piece can be moved in behind it to protect it. Here is an example Black Moves W W W W W W W W W W W W B B B B B B B B B B B B White Blocks W W W W W W W W W W W W B B B B B B B B B B B B 2 Move pieces out of danger if any piece is being threatened, and a piece cannot block for that piece, then it will attempt to move out of the way. If the piece cannot move out of the way without still being in danger, the computer ignores the piece. 3 If the computer player owns any kings, it will attempt to 'hunt down' enemy pieces on the board, if no moves can be made that won't in danger the king or any other pieces, the computer ignores this rule. 4 Any piece that is owned by the computer that is in column 1 or 6 will attempt to go to a side. When a piece is in column 0 or 7, it is in a very strategic position because it cannot get captured while it is in either of these columns 5 It makes an educated random move, the move will not indanger the piece that is moving or any piece that is on the board. 6 If none of the above are possible it makes a random move. This question is not really specific to any language but if all examples could be in Java that would be great, considering this app is written in android. Does anyone see any room for improvement in this algorithm? Anything that would make it better at playing checkers?


Algorithm to modify a color to make it less similar than background I'm creating a demo of 20 balls bouncing each other, with a background filled with a solid color. Color for each ball is chosen randomly with randint(0, 255) for each R, G, B tuple component. Problem is some balls end up with a color that is very similar to background, making them hard to see. I would like to avoid that, either by rolling another color if the chosen one is too similar (within a given threshold), or by moving it away from the background color. How to calculate a similarity index to use as a threshold? Or how to transform a color to make it, say, less blue ish? Obvious disclaimer I know nothing about color theory, so I don't know if the above concepts even exists! I'm coding in python, but I'm looking for concepts and strategies, so pseudo code is fine (or just the theory). EDIT To clarify a few points Each ball have its own random color. I'd like them to remain as random as possible, and to explore as much as possible of the color space (be it RGB or HSV, pygame accepts both formats for defining color) I'd just like to avoid each color of being "too close" to background. Problem is not just about hue I'm perfectly OK with a light blue ball against a dark blue background (or a "full blue" against a "white ish" blue, etc) For now, I don't care if a ball ends up with a color similar (or even identical) to another ball. Avoiding that is a bonus, but it's a minor issue. Background color is a constant, single RGB color. For now I'm using "basic" blue (0, 0, 255), but I'm not settled with that. So consider the background to be of an arbitrary color (with arbitrary hue, brightness, saturation, etc). EDIT2 TL,DR version Just give a way to create X random colors so that none "fades in too much" against a background of arbitrary (but single and constant) color


Raycast algorithm fails to collide with diagonal walls in specific locations I'm having a problem with my ray cast algorithm in a 2D tile based universe. I feel the situation would be best explained with a picture, so here it is The ray, represented by the blue line, is passing "through" the wall to hit its target when the wall passes through a point where the quantized line moves diagonally and the wall is perpendicular to it. The raycast function is as such def raycast(pos, direction, level) dx, dy direction t 0 x, y pos obj None while not obj and t lt 5000 t 1 x dx y dy obj level.get at((round(x),round(y)),True) pass return obj Is there a simple, efficient way to eliminate this kind of edge case?


What could I use to search tiles in a game I'm creating a tile based game similar to Minesweeper. When a user clicks on a tile and its not a mine or a number space I need to search and expose the adjacent tiles that are empty and stop when it hits a number or the edge of the board. I have it working right now so that it will clear the row of the tile clicked and stop at a numbered tile or the edge of the board. What I have is going to get ugly quickly and I am sure there is a easier way of doing this. Is there a searching algorithm I can use that will find all adjacent tiles to the one the player click only stopping once it hits the edge of the board or hit a numbered tile?


Pathfinding Search for Path of Specific Length I am creating a roguelike. This question applies to random map generation. First, I generate areas using a BSP algorithm, where I randomly divide the map into areas. Then, I generate a graph of the areas so that I can use search algorithms to generate paths through the map. It is easy to find the shortest path between two areas, but I would like to find a path with a specific number of steps(or path cost). So, my question is What is an algorithm that I can use to find a path that has a specific cost or cost range? An Example of why I think this is useful Say that I randomly choose two areas(start and end for example). These area might be next to each other, they might be on the opposite sides of the map. I want to force the player to travel through a minimum number of areas before reaching the end, let's say 5. I should be able to be like path startArea.findPathMinimumCost(endArea,5) And it will return a path of cost 5, or the shortest path, whichever has the greater cost. Thank you.


How do I produce "enjoyably" random, as opposed to pseudo random? I'm making a game which presents a number of different kinds of puzzles in sequence. I choose each puzzle with a pseudorandom number. For each puzzle, there are a number of variations. I choose the variation with another pseudorandom number. And so on. The thing is, while this produces near true randomness, this isn't what the player really wants. The player typically wants what they perceive to be and identify as random, but only if it doesn't tend to repeat puzzles. So, not really random. Just unpredictable. Giving it some thought, I can imagine hacky ways of doing it. For example, temporarily eliminating the most recent N choices from the set of possibilities when selecting a new choice. Or assigning every choice an equal probability, reducing a choice's probability to zero on selection, and then increasing all probabilities slowly with each selection. I assume there's an established way of doing this, but I just don't know the terminology so I can't find it. Anyone know? Or has anyone solved this in a pleasing way?


Help understanding Simplex Noise Introduction This is less of a "how to" on using 2D simplex noise and more of a quest to understand what is happening both in the math and visually. I would rather not copy and paste the code I've found. I really would like to understand it. I have done my homework on the subject and have read through Stefan Gustavson's paper and other sources many times. I feel like I understand about 70 of what my sources are saying, but when I try to manually follow my code loop through to check my understanding I either get hung up on what the variables represent or the math just doesn't add up. I have begun to rename the variables in the code I've found in order to better understand what's going on. If someone with some knowledge of what is actually happening can cross reference the original code (basically Gustavson's code) with my code that would be most excellent. I'm not actually done with renaming the variables though, partly because I'm stuck. My Understanding Let's say I pass pixel (2, 3) into my noise function. At this point I'm working with a normal grid and my goal is to translate this normal grid into a simplex. This simplex is in the form of many triangles since we're working in 2D and supposedly this is better for various reasons. To translate this point from the normal grid to the simplex grid, I must scale the point along the main diagonal line. After doing that, I apparently don't care about the decimals because I then Floor the results putting it back near the closest previous grid point. Now I'm going to align the simplex cell to the normal grid by unskewing the simplex cell. Why I do all this work to get to the simplex cell, then undo it I'm pretty hazy on. Seriously, I think the best way for me to understand this is if someone could whiteboard out in steps what the heck is going on here. Super lost. I didn't walk away empty handed though. I now have what I believe to be the distance between the original grid point I passed in and the simplex point I translated from that original grid point. Woo. I think I'll stop here for now, just because I don't want this to turn into a huge wall of text. I'm pretty sure the rest of this will click once I understand the the beginning part. Weird Math Using the (2, 3) point from earlier, this is what I get by stepping through my own code on paper x 2 y 3 skewfactor 1.830 unskewFactor 1.479 unskewed x 1.520 unskewed y 2.520 simplexCell i 3 simplexCell j 4 x distance0 1.520 y distance0 1.520 i1 0 j1 1 x1 1.309 y1 2.309 x2 2.5207 y2 2.5207 ii no idea why this isn't i2 or something like that. No idea what this is. jj same Not sure if plotting on a graph would work, but I tried and it looks so bad. I used the original parameters (2, 3), simplexCell i amp j, i1, j1, x1, y1, x2, and y2. Doesn't make any sense visually. Not just visually, but mathematically as well. What's with (2, 3) returning negative numbers that go off the chart? What am I doing wrong here?


Integrating specular, diffuse reflection and refraction I am implementing an MLT bidirectional path tracer. I have a problem integrating diffuse, specular reflection and refraction. 1) The first problem is diffuse and specular reflection. Diffuse reflection is done by sampling ray in a hemishere. But specular reflection is done by finding the ray that have an angle to the normal equal to the incident ray with the normal. However, an object can have both diffuse and specular reflection. When to use specular reflection or diffuse reflection for a ray? 2) Same as the first question but this time integrating reflection with refraction. I've seen a few research papers and websites online where the scene have specular, diffuse reflection and refraction, but they have no tutorial on how to do this.


AI discover algorithm I am curious as to what algorithm logic game AI NPCs would use when discovering information about their environment. There are two scenarios that I could envision. The NPCs are all knowing in regards to elements in the environment, but choose to ignore them unless certain conditions are met (e.g. the guard will not "find" his fallen comrade's body unless he is x feet from the body) The NPCs really do discover the environment by scanning it or something... (maybe similar to path finding?) Maybe these are both used in conjunction... Could anyone point me in the right direction towards any preferred methods? I tried googling for this information, but could not find anything that seemed relevant.


Randomly generating the hallways between a network of rooms So here's my base map (It won't necessarily be 5x5, just using this as an example.) It's kinda boring the way it is with all the rooms connected. I want it to be more of a randomly generated labyrinth, where every room is accessible like so I've tried setting the hallways randomly foreach(Room r) r.northWall randomBoolean() r.southWall randomBoolean() r.eastWall randomBoolean() r.westWall randomBoolean() But that almost always ends up with rooms that you're unable to go to, like this And often some rooms have no hallways at all. I tried saying each room must have a minimum of 2 hallways, but it still doesn't fix the problem that sometimes there an inaccessible areas. How should I go about doing this? I'm not too worried about the speed, as long as it's not ridiculously slow (Some levels will have 100 rooms).


Swept AABB vs Line Segment in 2D I've been trying to get a swept collision detection up and running now for almost a week and I can't for the life of me get it working. There is a answer on this linked here below Swept AABB vs Line Segment 2D I've translated this into Go which will be running the game server and needs this logic func SweepRectLine(rectX, rectY, rectW, rectH, rectHSpeed, rectVSpeed, lineX1, lineY1, lineX2, lineY2 float64) (bool, float64) outVel 2 float64 hitNormal 2 float64 lineNX, lineNY lineX2 lineX1, lineY2 lineY1 lineMinX, lineMaxX, lineMinY, lineMaxY math.Min(lineX1, lineX2), math.Max(lineX1, lineX2), math.Min(lineY1, lineY2), math.Max(lineY1, lineY2) var lineMinX, lineMaxX, lineMinY, lineMaxY float64 if lineNX gt 0 lineMinX, lineMaxX lineX1, lineX2 else lineMinX, lineMaxX lineX2, lineX1 if lineNY gt 0 lineMinY, lineMaxY lineY1, lineY2 else lineMinY, lineMaxY lineY2, lineY1 r (rectW 2) math.Abs(lineNX) (rectH 2) math.Abs(lineNY) radius to Line boxProj (lineX1 rectX) lineNX (lineY1 rectY) lineNY velProj rectHSpeed lineNX rectVSpeed lineNY if velProj lt 0 r 1 hitTime math.Max((boxProj r) velProj, 0) outTime math.Min((boxProj r) velProj, 1) log.Println( quot start quot , hitTime, outTime) rectXMax, rectXMin rectX rectW 2, rectX rectW 2 if rectHSpeed lt 0 left if rectXMax lt lineMinX return false, 0 hitTime math.Max((lineMaxX rectXMin) rectHSpeed, hitTime) outTime math.Min((lineMinX rectXMax) rectHSpeed, outTime) else if rectHSpeed gt 0 right if rectXMin gt lineMaxX return false, 0 hitTime math.Max((lineMinX rectXMax) rectHSpeed, hitTime) outTime math.Min((lineMaxX rectXMin) rectHSpeed, outTime) log.Println( quot right quot , hitTime, outTime) else if lineMinX gt rectXMax lineMaxX lt rectXMin return false, 0 if hitTime gt outTime return false, 0 rectYMax, rectYMin rectY rectH 2, rectY rectH 2 if rectVSpeed lt 0 up if rectYMax lt lineMinY return false, 0 hitTime math.Max((lineMaxY rectYMin) rectVSpeed, hitTime) outTime math.Min((lineMinY rectYMax) rectVSpeed, outTime) else if rectVSpeed gt 0 down if rectYMin gt lineMaxY return false, 0 hitTime math.Max((lineMinY rectYMax) rectVSpeed, hitTime) outTime math.Min((lineMaxY rectYMin) rectVSpeed, outTime) else if lineMinY gt rectYMax lineMaxY lt rectYMin return false, 0 if hitTime gt outTime return false, 0 outVel 0 rectHSpeed hitTime outVel 1 rectVSpeed hitTime return true, hitTime I also put up a Gist with a executable UI here https gist.github.com KidLinus 3f847c46b0e6dc1addac7252d9cb54ab I can't for the life of me figure out what all class variables stand for. I think that some of them are native to Unity but that's just a guess. I've come so far as to figure out that the extent is half of the width height in said direction. What the quot line.n quot stands for is anyones guess, I assume its the direction and have no idea if it's normalized or not. There are also a couple of dead variables just laying there.


How can I divide a 3D mesh into small pieces? I'm considering a manufacturing game. A player should assemble parts of an object in given time. The object will be a 3D mesh model. I want to automatically split the 3D mesh into many small pieces to be provided to players. Each divided piece is needed to have area as similar as possible. And I want to control the number of pieces too within range about 2 6. How can I do this? I know the method to modify a given mesh like adjusting values of vertices, indices. All I need is the algorithm.


Chunked QuadTree creation handling I am new to LOD based techniques so please be lenient with your comments about my naive questions. Preface My aim is a simple terrain renderer (preferred C and OGL) that is to load a height map (say 990 x 990 x 8bit) organized into 33x33 vertex chunks. No on demand paging, just the sampling vertices from the height map data directly into the vertex buffers of the chunks. The rendering should be done via a quadtree whereas the leafs would render a whole chunk (33x33 vertices). After reading Thatcher Ulrich's "Adaptive Quadtree" article, as well as chunked LOD and quite many other articles and questions on stack exchange, I still seem to be too stupid to wrap my head around on how to actually proceed. Ulrich rendered leafs as triangle fans directly (in his demo code) which was appropriate at that time (I guess) but my prerequisite is a batch of triangles at once, hence the chunked approach. 1) Using a quad tree (which is easy enough to understand, at least conceptually, and will presumably not lead to patent wars later as with e.g. 'geo mipmaps'), at some point the tree will have to be created. My guess was to load (or generate) a height map first and then PRECALCULATE a quad tree based on this map. Would that be a viable approach? Various articles seem to expect the reader to know this fact a priori, so it is nowhere clearly stated. If pre calculated, then all possible child nodes would be pre allocated in the RAM and walked top down with some distance to node by width LOD criteria that would force the child nodes to take over. 2) If pre allocated, HOW would one render the chunks if lower LOD is required. I.e, the chunk being 32x32 quats 33x33 vertices, an index buffer holding 33x33 indices would render the whole chunk as is. Now, a neighbor node with one lower LOD level is not a leave anymore, and its index buffer would not only need to span the four chunks of it children, it would also have to have an index buffer that indexes every second vertex as well to maintain only a single level of difference (or so my understanding). So I guessed (again) that EVERY node (leaf or not) would have to have (at least) one index buffer, and this index buffer would also have to be created calculated during creation of the entire tree. (Which I would place in the engine's loading section, not anywhere close to the rendering loop). What I really don't understand is, how to do the rendering with the above approach (if it were the way to go, that is)... When nodes way above (in terms of lower LOD level, i.e. coarser resolution) must draw their content, would that mean that the vertex buffers of ALL chunks (in the leaf nodes way down) must be bound? And how would the index buffer of this node address the vertices in all the chunks?... Or, would one have an empty 33x33 patch standing to the ready to collect vertices from various chunks as indexed by this lower level node? (Sounds cheesy already whilst writing this...) I would love to see an answer to this. I would accept a NO CAN DO with quadtrees and alternative suggestions, but a quad tree solution is what I hope for. My own alternative solution (which is a whack job on my mind though) is a kinda 'Infinite Snapshot Quadtree' that starts with a root and creates nodes on the fly, but does only store as many nodes as required to render the visible world. A node however must carry all information to recreate its parent as well as to be able to create a chunck geometry. The subdivision depth with this approach is (virtually) infinite (not considering issues with precision here), but the neighbor linking mayhem is beyond good and evil... Best Regards. Edward


How can I generate Worms style terrain? I'm working on a Worms styled game and want to generate some terrain procedurally. I've previously done a lot of terrain generation using perlin noise, and this is what I started out using for this game. The only problem with it is that it's too simple and boring, giving me some hills but not the complexity I want. I'd like to have features like caves and hanging mountains and I don't mind floating islands and such. Something like this, but even crazier would be ok I thought of first generating the terrain using classic perlin noise, then just removing parts to create caves and what not, but I'm having trouble guiding the removal of those parts. Are there any alternatives to generating such a terrain?


Looking for a square to hex pixel coords algorithm So as the headline suggests, I am looking for an algorithm algorithms used for square to hex and hex to square pixel coordinates convertion. I have an image which looks kinda "interpolated", meaning some pixels are of one colour, while some have a slightly different shade etc. So pixel colour kinda stores offset or whatever. If you're interested, it's here It has to do with pathfinding, the logical part of map is made of hexmap while the visual part of map is made of squares. Here, size of the square 1 pixel, same hex size is equal to 1 pixel. So basically I will be trying to convert an image with hex pixel coords to image with square pixel coords and vise versa. I'm sorry if this was answered already somewhere, I couldn't find it anywhere. P.S. I reverse engineered the image, so in binary it was only X and Y coords stored plus a third byte value which I took as a greyscale colour (later compared with another image and it matched) Image


Algorithm to produce 'Lady or Tiger' puzzles? What my problem is There is a puzzle by Raymond Smullyan that works something like this You are in a room with many doors. Behind some of those doors, there are ladies behind the others, there are tigers. Your goal is to pick one of the right doors (the ones with the ladies). On every door, there's a sign that says something like There's a lady behind this door or There is a lion behind door II and VI and so on. Now, you also have some additional information like Only one of the signs says the truth or The sign on a door is true only if there is a lady behind that door and so on. For example, the first puzzle goes like this There are two doors with one sign each. One of the signs is true, the other one is false DOOR I DOOR II There's a lady in In one of those this room and a rooms, there's a a tiger in the lady, in the other other one one there's a tiger Behind which door is a lady? Now, getting to the topic of this question I'm looking for possible ways to auto generate such puzzles. The (far away) goal is to build an algorithm that requires, as parameters, the number of doors (and maybe the difficulty of the resulting puzzle) and creates corresponding texts for the doors. What I have tried so far Not much, as I don't really know where to start. It's easy to create a pattern for the text on the signs and it's also easy to randomly assign true and false statements to those signs, corresponding to the true false rule you use (e.g. Only one sign says the truth). But that's the part where it get's tricky How to create a puzzle that is solvable and has a unique solution? My first idea was to create a random puzzle and use backtracking to search for solutions. But that way, it could take very long until the algorithm has finally found a working set of signs. Also, that way you can't easily determine how difficult a given puzzle is. So, summing it up Do you have any idea, any helpful links, etc.? Any help is appreciated, I don't expect anyone to post a perfect and complete solution for my problem. (Note I originally asked the following question on stackoverflow but was told there that I would be more likely to get an answer here!)


Rendering mountains around a tile layer When making a 2D Pok mon game, I just faked elevation by putting mountain tiles underneath the land. Now my tiles are 3D models, so I'm using layer properties to define their elevation. What I don't know though is how to generate a 'mountain' around them. The tilemap is kinda' like this Layer 1 Layer 2 Layer 3 .... .... .. . .... .. .... Layer 2 has y offset set to 1, and Layer 3 has y offset set to 2. All they do right now is float in the air. What I'm trying to do is render a mountain around them.


What maps sizes did old 2D RTS games like C C and WarCraft support? I'm looking for the size (in tiles) of the maps for the old 2D games Command and Conquer and Warcraft 1 and 2.


Manually creating cycles in planar, procedural trees? I am creating a procedural map using delaunay triangulation and an MST. I'd like to have a bit more control over my final graph. Like when i was looking looking at the MST I wondered how I can connect specific points of the MST? The following image shows the MST in green and the points I want to connect in red. I was thinking about traversing from a dead end and counting the steps. When it gets within a certain treshhold add a connection. But this might add a connection when there is still a room closer to it. So I have to check for that as well. Same goes for entrance, exit and perhaps other important places on the graph. I want to end up with a random yet fun and playable dungeon. There must be proven concepts about controlling a graph for procedural dungeons and I would love to learn from it.


UNITY How do I use SetTile() with a tile asset scriptable tile? How do I use Tilemap.SetTile() with a tile asset? I want to use it for scriptable tiles in the 2d extras package, such as rule tiles, weighted random tiles, and animated tiles. How would I 1. get inspector reference of this scriptable tile, and then 2. use SetTile() with it? Thanks for your attention.


Is it bad practice to use the entire map image as a tilemap? I made a map in photoshop which I want to use as a map in my game. The question is should I try to cut it up to pieces, or is it bad (performance wise) if I use the way I made it. The picture itself is really specific without any repeatable part so I'm not sure if I can cut it up to smaller parts. I'm kinda new to game developement, so pls forgive me if I asked something stupid here.


Webgl pixel perfect tilemap rendering? The problem described below is a follow up of Seamless tilemap rendering (borderless adjacent images). I'm not sure to fully understand the rendering issue I have, so I'll try to describe as much as I can. I had "seams" when rendering a tile map of tiles of 16px by 16px, more precisely I was seeing the following I followed the recommendations describes in this answer. It solved entirely the previous problem. However I now have the following rendering issue As you can see, everything is blurry. I have also tried to do what is recommended in this answer, but it didn't change anything. I got the exact same output. Last note, this is not always visible. When changing the position and scale of the camera, the rendering can end up being correct. This is quite random though. If you are interested in seeing some code, please have a look on the following links This gives you a rough idea of the pipeline executed This is where the texture coordinates are generated This is where the buffers are instantiated This is the fragment shader This is the vertex shader If you think you need more details, please feel free to ask me.


Scrolling background in PyGame with Entity Component System I know this type of question has been asked to death for 'normal' games, however I am struggling with relating a scrolling background to an entity component system (ECS) approach. Generic samples here and here and here. What I struggle with is how to take a fairly procedural view of this problem and abstract it out to an ECS. I'm trying to get a roguelike game up and running in PyGame using Esper. I do have a proof of concept up and running where I generate a large map, however I'm having issues relating how to add a camera here as an entity that other objects would relate to. I'm guessing that I need to refactor my movement code to be based around a camera, and have each separate entity update their relative position as a result. At present, the background is being directly drawn and needs to be abstracted to an Entity in this system, but I was somewhat holding off on that until I figured out the camera. Here is a snippet of the Renderable class that each drawn entity has class Renderable def init (self, image, posx, posy, depth 0) self.image image self.depth depth self.x posx self.y posy self.curr row, self.curr col convert to cells(posx, posy) self.w image.get width() self.h image.get height() self.rect pygame.Rect(self.x,self.y,self.w,self.h) And here are the Movement processor and Render processors class MovementProcessor(esper.Processor) def init (self, minx, maxx, miny, maxy, game map) super(). init () self.minx minx self.maxx maxx self.miny miny self.maxy maxy self.game map game map def process(self) This will iterate over every Entity that has BOTH of these components for ent, (vel, rend) in self.world.get components(Velocity, Renderable) Check if movement is valid newx rend.x int(vel.x TILE SIZE) newy rend.y int(vel.y TILE SIZE) new row, new col convert to cells(newx, newy) if self.game map.data new row new col gt 1 Update the Renderable Component's position by it's Velocity rend.x newx rend.y newy rend.curr row new row rend.curr col new col class RenderProcessor(esper.Processor) def init (self, window, clear color (0, 0, 0)) super(). init () self.window window self.clear color clear color def process(self) Clear the window self.window.fill(self.clear color) This will iterate over every Entity that has this Component, and blit it for ent, rend in self.world.get component(Renderable) self.window.blit(rend.image, (rend.x, rend.y)) Flip the framebuffers pygame.display.flip() Later on in my main loop I iterate over my tilemap (Map class) and simply draw it to a surface, add some debugging overlays, and then assign that surface to the entity associated with the background (bg entity) Blit background directly this needs to be abstracted out for row in range(len(game map.data)) for col in range(len(game map.data 0 )) rect pygame.Rect(col TILE SIZE,row TILE SIZE,TILE SIZE,TILE SIZE) Blit a wall sprite if game map.data row col in 0,1 bg surface.blit(walls game map.data row col ,rect) Blit a floor grass sprite elif game map.data row col in 2,3,4,5 bg surface.blit(floors game map.data row col 2 ,rect) Here is the full listing https pastebin.com N7c4TXXB


Find all tiles by ID in layer In phaser 2.6.2, is there a way to retrieve all tiles given their ID from a TilemapLayer? The method searchTileIndex on Tilemap works well to retrieve a tile. It has a skip parameter that allows to loop through the tiles, so I've come with the following code var walls var skip 0 do var tile map.searchTileIndex(Tiles.ID WALL, skip, false, wallLayer) if (tile ! null) walls.push(tile) skip while (tile ! null) but it looks very cumbersome to say the least. Am I missing a simpler method, kind of getAllTiles(id) or something?


Hexagonal tilemap is being distorted So I made a hexagonal tilemap of ocean tiles and then picked a few tiles to be land. When I pick all adjacent tiles to the hexagon it usually works, but for tiles that are on certain columns it does not. Also, on these columns the tops and bottoms of tiles are missing. It's hard to explain but here's a screenshot that should clear it up As you can see, on every other column the top and bottom of hexagons are missing, when all adjacent tiles are filled in to the centre tile it works fine for those columns without a bottom and top on hex, but when it's on the other column one of the adjacent tiles is displaced. Any suggestions? Code baseLayer.setCell((int)islands currentTile .x , (int)islands currentTile .y, landCell) baseLayer.setCell((int)islands currentTile .x 1, (int)islands currentTile .y 1, landCell) baseLayer.setCell((int)islands currentTile .x 1, (int)islands currentTile .y, landCell) baseLayer.setCell((int)islands currentTile .x , (int)islands currentTile .y 1, landCell) baseLayer.setCell((int)islands currentTile .x 1, (int)islands currentTile .y, landCell) baseLayer.setCell((int)islands currentTile .x , (int)islands currentTile .y 1, landCell) baseLayer.setCell((int)islands currentTile .x 1, (int)islands currentTile .y 1, landCell)


How can I generate a TileSet from an existing image of a level? Let say I have this level from Zelda ALTTP. I know that each tiles are 16x16. How can I generate a tileset and map from part of the original image? (Image source)


Best practice for map coordinate system Are there any conventions and or best known methods around coordinate systems in game maps? Is the origin usually positioned in the center of the map? Or does it live in a corner and the map is built in a single octant of the 3D space?


Find connected hex of same color I'm using Lua. I have a hex map. It is randomly generated into an table. hexmap y x .color "red" I wish to find each "group" of hex's. i.e. all hex's of the same color that connect to each other will belong to one group. As an example, in the following image The result should be 1 blue group (all hex's connect) 3 green groups 1 black group Any suggestions? Thank you.


Divide a tile map into multiple images So let's say I have a tilemap 5 x 5, which equals 25 tiles. How can I divide my tilemap into 25 different images? I'm using tiled, but I don't know if it is possible to do it on there or if I need to use one other program. Of course, my tilemap is bigger than 5 x 5, so it's why I'm asking because it would consume a lot of my time. Thanks.


Tilemap Object Placement I am looking for a way to select tiles within a bounding box for object placement within a scene world, similar to Roller Coaster Tycoon and other simulation games. (source tumblr.com) In the above screenshot of Theme Parkitect you can see that a 4x4 grid is used as the footprint for the object being placed. Given the bounding box and location of the mouse, how can I suitably determine the neighbouring tiles which fall into the bounding box? I have implemented a graph like structure of tiles, corners and edges by following Amit's fantastic articles on Red Blob Games. As of such, I have a graph of all tiles and their neighbours as well as associated tile edges and corners. These tiles are laid out diagonally against the world axis so simply selecting all tiles within a rectangular region isn't as simple (or maybe it is?) as i'd expected. This layout can be changed if necessary however. The main source of information used to steer my implementation has been from Amit's Thoughts on Grids and the graph structure implemented in his article about Procedural Map Generation As a bonus, I would like to implement a way to rotate the object being placed such that a footprint of 1x5 could be rotated to instead be 5x1. I would imagine that once the basics of multiple tile picking has been implemented this should be reasonably simple. Unfortunately, Amit's articles don't seem to cover this topic and the approaches I have found and tried so far haven't quite yielded the correct results. Any help that fits in with the graph like structure for connected tiles, edges and corners would be greatly appreciated. I have tried to implement the approach outlined in Raytracing on a Grid with a mixture of both Broad Phase collision and A Path Finding but neither of these two approaches cover selection of multiple surrounding tiles. I am not concerned with the viability of tiles for placing objects at this point (i.e. sloped edges of tiles or obstructions from other objects). The ideal solution for now would simply be to find the tiles included within the bounds. My initial forays into this have resulted in incorrect results whereby the bounding rect doesn't include all neighbouring tiles (sometimes missing entire rows columns) or returning neighbours outside of the bounds. I was pretty sure that I was close to a winning implementation but my vector math isn't strong enough to validate my findings.


Store metadata for tile in Tiled Map Editor In my tilemap based game, I need to associate lights with light switches, buttons with doors etc. I am using the Tiled map editor (mapeditor.org), but I have yet to find a way to store these associaltion. My idea is to store a number with each tile, so I can have groups of tiles that interact with each other. Is there a way to store custom data with each tile in the Tiled map editor? Just to be clear I don't want to store custom data with each tile type, but with individual instances of one tile type.


Is it possible to make a TileMap that adjust it self to multiple screens? I need to build a tile map that is supposed to fit nicely in several screen Sizes. However, Tiled the tile map editor I use allows only to produce absolute fixed size tile maps. Is there an easy way to make adaptable tile maps or should I build one for each screen size?


Top down tile based game render order I'm making a simple top down (like this) tile based game (using JavaScript, for reference) I use Tiled for making maps. I have sprites that are more than one tile high, and so whenever they are in front or behind of some objects more than one tile high tiles will be displayed in front of the player. I am looking for a way to give certain tiles 'height' such that only characters of that height could appear in front of those tiles. Here is a screenshot showing my problem (the sprite is doge because it was the first image I found) The same tiles don't always equate to the same height, so I can't give tiles set height. I've thought of one way to give tiles height, and that is to have a (hidden) layer that describes the height level certain tiles are at. However, that solution would be slow and painful to implement. I'm wondering if there's a better way to do it. A few other potential ideas I've had Have a tile layer for each height, hackily guess the height of a tile at runtime based on tiles below (would be buggy) but I think that there would surely be a better way to do it.


How to handle tiles on top of players I am creating an 2d bird view tile game using the pixijs render framework. Like pokemon or oldtime zelda. In those games you sometimes walk behind buildings where the tile would be drawn on top of the player. I am using an multidimensional array for each tile properties. Where you can set ground level images and level on top of ground level images. The 'z index' can be changed. Should I create an new property to flag it as an tile that can be on top of the player? Where all those tiles with that property are drawn on top of the player. But there is an possibility that you can climb walk on the building and the player should than be drawn on top of the tiles. You should take the following into consideration the game is an multiplayer game. This could be an conflict if all the players characters (the player,npc, cpu) are one layer and the tiles that can be drawn on top of the player are one layer. Because for example one player is walking on top of the building and one is behind the building. You cant change the z index of the player one lower. Because the player behind the building wil look like he is on top of it because the player is drawn on top of it by the changed z index. you can be drawn on top of the tile level (like walking om top of the building or mountain) tiles can change (a building that is going to be destroyed for example) thus are not fixed So how can I handle tiles on top of a player which can be also beneath one player but not the other?


Animal Crossing like Map Data Structure I've been looking closely at how Animal Crossing (for GameCube) creates town maps, and as far as I can tell, it's something like this The town is made up of a 5x6 grid of acres. Each acre is 16x16 "tiles" in size. That's the easier part. As for the actual map generation, it seems to use what I'll call "acre templates." That is, the acres seem to be selected somewhat randomly from a predefined list, with predefined layouts. So there are, for example 2 different layouts of what an acre containing the Museum will look like. Or if an acre has a river running through it, top to bottom, there might be 3 4 different templates of how the river flows through that acre, with optional ponds nearby, etc. The question is... What is a good suggestion or method for how to organize the data structure to handle all of this? Another thing to keep in mind is that there's a "second layer" of objects on top of the basic terrain info, such as trees or rocks or inventory objects dropped buried on in the ground. How would I store that information in relation to the acre templates?


Tilemap layer scaling and Camera issue in Phaser I'm working with the Phaser framework and I'm struggling with a camera rendering issue when scaling a tilemap layer to simulate a zoom feature in my project. The camera size is set to 1024x768px.(Same as the stage size) I then create a tilemap and a tilemap layer that is 3072x2304px. Create the tilemap and the tilelayer this.map this.add.tilemap() this.map.addTilesetImage('tiles') this.layer1 this.map.create('layer', 96, 72, 32, 32) this.layer1.resizeWorld() Code to zoom this.layerScaleGroup this.add.group() this.layerScaleGroup.add(this.layer1) this.layerScaleGroup.add(this.marker) this.layerScale 1 this.inputScale 1 In the update function if(this.input.keyboard.isDown(Phaser.Keyboard.Q)) this.layerScale .2 this.inputScale .2 if(this.input.keyboard.isDown(Phaser.Keyboard.A)) this.layerScale .2 this.inputScale .2 this.layerScale Phaser.Math.clamp(this.layerScale, .33, 1) this.inputScale Phaser.Math.clamp(this.inputScale, 1, 3) this.layerScaleGroup.scale.set(this.layerScale) this.input.scale.set(this.inputScale) When completely zoomed out I need the tilemap layer to be shown in the camera, but instead it seems like the camera or a camera follows the scale of the tilemap layer, even though the original camera is still 1024x768. Here is a video showing the issue. https youtu.be e2mRfigq98I When you are zoomed out you can still draw a tile onto the tilemap, but it is not rendered.


Touch Gesture Map Movement I really dig the way that the map is moved in Clash of Clans (https itunes.apple.com ca app clash of clans id529479190?mt 8)... I can recognize the pinch and finger movement needed for the zooming and the swiping around the map, what I'm looking for is a tutorial in any language that reveals how to test for the map going out of bounds when moved or scaled. My google fu has failed so far on this one, any hints? Right now I can perform the scale operations and the movement operations, but I can't figure out how to stop the map from going out of bounds when pinched or scaled. My code is a crazy mess and makes me think I'm missing the fundamental logic of how this is done. (I am using Starling with AIR, but a tutorial in any language if you have a link). Update this is what I'm basing what I have currently so far https github.com PrimaryFeather Starling Framework blob master samples demo src utils TouchSheet.as


Godot How to get mouse button input for a Tilemap for Cellular Automata Conway's Game of Life I have been working with a tilemap for the implementation of a cellular automata game. My current method for getting mouse button input is using an Area2D as a child of the Tilemap and detecting mouse button input like that. I have done this and have since been wondering if there is something built in that I can use for this. I have looked into it and cannot find anything better. Is there something built in to Node2Ds or Canvas Items that I can use.


Cocos2dx v3 Problem with moving Sprite on tilemap after it was scrolled up I have a problem I can't solve so far. I have a scene with tile map on it. And there is a Sprite spawnpoint on map. This Sprite should do MoveTo() action to the point where TouchEnded(). It all works perfectly in the borders of the screen, but after I scroll my map up and do touch again my Sprite stuck in the max Y point of the screen. (Let's say there is max 480px of screen's Y, but 850px of tile map) Please help!


Segmentation Fault using Allegro Tiled, function al open map() I have consistently segfaulted trying to load a TMX file into a map. int main(int argc, char argv ) ALLEGRO DISPLAY display NULL ALLEGRO EVENT QUEUE event queue NULL ALLEGRO TIMER timer NULL ALLEGRO KEYBOARD STATE keyboard state ALLEGRO MAP map al open map("data maps", "TestMap.tmx") ... Active debugger config GDB CDB debugger Default Building to ensure sources are up to date Selecting target Debug Adding source dir home X Desktop Programming C AllegroRoboticsTest Adding source dir home X Desktop Programming C AllegroRoboticsTest Adding file home X Desktop Programming C AllegroRoboticsTest bin Debug AllegroRoboticsTest Changing directory to home X Desktop Programming C AllegroRoboticsTest . Set variable LD LIBRARY PATH . usr local lib opt opencascade lib Starting debugger usr bin gdb nx fullname quiet args home X Desktop Programming C AllegroRoboticsTest bin Debug AllegroRoboticsTest done Setting breakpoints Debugger name and version GNU gdb (GDB) 8.1 Program received signal SIGSEGV, Segmentation fault. In al get standard path () ( usr lib liballegro.so.5.2) 2 0x00005555555563ba in main (argc 1, argv 0x7fffffffe3a8) at home X Desktop Programming C AllegroRoboticsTest main.c 45 At first I thought, maybe I just didn't build the library right, so I rebuilt it 2 more times, once as a static and another as a shared library. The interesting thing is that it builds just fine when using the cmake files that came in the example. I cannot recreate it though. This is the callback after I moved the open map command into it's usual place, directly from the example that comes with allegro tiled. If MAP FOLDER is relative to the working directory and not the running executable, then add a call to al find resources as(RELATIVE TO CWD) before calling al open map() . al find resources as(RELATIVE TO CWD) map al open map("data maps", "TestMap.tmx") int map total width al get map width(map) al get tile width(map) int map total height al get map height(map) al get tile height(map) Draw the map al clear to color(al map rgb(0, 0, 0)) al draw map region(map, map x, map y, screen width, screen height, 0, 0, 0) al flip display() ... Setting breakpoints Debugger name and version GNU gdb (GDB) 8.1 Child process PID 25749 In strtoll l internal () ( usr lib libc.so.6) 3 0x0000555555556615 in main (argc 1, argv 0x7fffffffe3a8) at home X Desktop Programming C AllegroRoboticsTest main.c 114


How to implement different shapes for an area of affect spell? Let W wizard Let 0 Cast range of spell, or AOE Here is the problem I have a 2D tile map of squares. Let's say I want to have a wizard cast a spell that surrounds his body equally. For this, it would be as simple as using a flood fill or Dijkstra's algorithm, and it would look like this 0 00000 000W000 00000 0 No problem! However, how will I implement a spell, that, for whatever reason, looks like a plus sign? 0 0 000W000 0 0 Or the spell goes longer in the direction the wizard is facing? 00000 00000 0W0 000 Or two different locations? 00 W 00 Or, even more awkward, its a ranged splash spell where the player can choose where they want to cast it? W 0 00 One way would be to have a list of all the locations relative to the wizard beforehand, and add them to the wizards location later. (E.g, for the affect to be 2 tiles north of the wizard, it would store (x 0, y 2), and later add them to the wizard's position, which could be at x 30, y 19, so the affect would be at x 30, y 21.) A limitation to this, unfortunately, is that it doesn't take into account where the wizard is facing, and it feels inelegant to manually typing in all the locations that the AOE will affect. Bottom line How should I approach this problem and create a good, easily adjustable AOE system for a tile based map, that takes into account different AOE shapes and cast positions?