Search Results

Search found 753 results on 31 pages for 'hexagonal tiles'.

Page 9/31 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Creating a tiled world with OpenGL

    - by Tamir
    Hello, I'm planning to create a tiled world with OpenGL, with slightly rotated tiles and houses and building in the world will be made of models. Can anybody suggest me what projection(Orthogonal, Perspective) should I use, and how to setup the View matrix(using OpenGL)? If you can't figure what style of world I'm planning to create, look at this game: http://www.youtube.com/watch?v=i6eYtLjFu-Y&feature=PlayList&p=00E63EDCF757EADF&index=2

    Read the article

  • Rotating A Tile In A BufferedImage

    - by Eddy Freeman
    I have created a a bufferedImage of 6 tiles of 2 rows and 3 columns and i want to rotate the last tile of the second row. This tile serves as a crossing for my animation. My problems are : How can i get access to that specifc tile alone and rotate it alone without affecting others. I have googled for a while but no answer.

    Read the article

  • How to draw/manage a hexagon grid?

    - by W.N.
    I've read this article: generating/creating hexagon grid in C . But look like both the author and answerer have already abandoned it. v(hexagonSide - hexagonWidth * hexagonWidth): What's hexagonSide and hexagonWidth? Isn't it will < 0 (so square root can't be calculated). And, can I put a hexagon into a rectangle? I need to create a grid like this: One more thing, how can I arrange my array to store data, as well as get which cells are next to one cell? I have never been taught about hexagon, so I know nothing about it, but I can easily learn new thing, so if you can explain or give me a clue, I may do it myself.

    Read the article

  • Combine Arbitrary number of polygons together

    - by Jakobud
    I have an arbitrary number of polygons (hexes in this case) that are arranged randomly, but they are all touching another hex. Each individual hex has 6 x,y vertices. The vertex's are known for all the hexes. Can anyone point me in the direction of an algorithm that will combine all the hexes into a single polygon? Essentially I'm just looking for a function that spits out an array of vertex locations that are ordered in a way that when drawing lines from one to the next, it forms the polygon. This is my method so far: Create array of all the vertices for all the hexes. Determine the number of times a vertex occurs in the array If vertex is in the array 3+ times, delete the vertices from the array. If vertex is in the array 2 times, delete one of them. The next step is tricky though. I'm using canvas to draw out these polygons, which essentially involves drawing a line from one vertex to the next. So the order of the vertices in the final array is important. It can't be sorted arbitrarily. Also, I'm not looking for a "convex hull" algorithm, as that would not draw the polygon correctly. Are there any functions out there that do something like this? Am I on the right track or is there a better more efficient way?

    Read the article

  • How do I randomly generate a top-down 2D level with separate sections and is infinite?

    - by Bagofsheep
    I've read many other questions/answers about random level generation but most of them deal with either randomly/proceduraly generating 2D levels viewed from the side or 3D levels. What I'm trying to achieve is sort of like you were looking straight down on a Minecraft map. There is no height, but the borders of each "biome" or "section" of the map are random and varied. I already have basic code that can generate a perfectly square level with the same tileset (randomly picking segments from the tileset image), but I've encountered a major issue for wanting the level to be infinite: Beyond a certain point, the tiles' positions become negative on one or both of the axis. The code I use to only draw tiles the player can see relies on taking the tiles position and converting it to the index number that represents it in the array. As you well know, arrays cannot have a negative index. Here is some of my code: This generates the square (or rectangle) of tiles: //Scale is in tiles public void Generate(int sX, int sY) { scaleX = sX; scaleY = sY; for (int y = 0; y <= scaleY; y++) { tiles.Add(new List<Tile>()); for (int x = 0; x <= scaleX; x++) { tiles[tiles.Count - 1].Add(tileset.randomTile(x * tileset.TileSize, y * tileset.TileSize)); } } } Before I changed the code after realizing an array index couldn't be negative my for loops looked something like this to center the map around (0, 0): for (int y = -scaleY / 2; y <= scaleY / 2; y++) for (int x = -scaleX / 2; x <= scaleX / 2; x++) Here is the code that draws the tiles: int startX = (int)Math.Floor((player.Position.X - (graphics.Viewport.Width) - tileset.TileSize) / tileset.TileSize); int endX = (int)Math.Ceiling((player.Position.X + (graphics.Viewport.Width) + tileset.TileSize) / tileset.TileSize); int startY = (int)Math.Floor((player.Position.Y - (graphics.Viewport.Height) - tileset.TileSize) / tileset.TileSize); int endY = (int)Math.Ceiling((player.Position.Y + (graphics.Viewport.Height) + tileset.TileSize) / tileset.TileSize); for (int y = startY; y < endY; y++) { for (int x = startX; x < endX; x++) { if (x >= 0 && y >= 0 && x <= scaleX && y <= scaleY) tiles[y][x].Draw(spriteBatch); } } So to summarize what I'm asking: First, how do I randomly generate a top-down 2D map with different sections (not chunks per se, but areas with different tile sets) and second, how do I get past this negative array index issue?

    Read the article

  • Most efficient way to save tile data of an isometric game

    - by Harmen
    Hello, I'm working on an isometric game for fast browsers that support <canvas>, which is great fun. To save information of each tile, I use a two-dimensional array which contains numbers representing a tile ID, like: var level = [[1, 1, 1, 2, 1, 0], [0, 1, 1, 2, 0, 1], [0, 1, 1, 2, 1, 1]]; var tiles = [ {name: 'grass', color: 'green'}, {name: 'water', color: 'blue'}, {name: 'forest', color: 'ForestGreen'} ]; So far it works great, but now I want to work with heights and slopes like in this picture: For each tile I need to save it's tile ID, height and information about which corners are turned upward. I came up with a simple idea about a bitwise representation of all four corners, like this: 1011 // top, bottom and left corner turned up My question is: what is the most efficient way to save these three values for each cell? Is it possible to save these three values as one integer?

    Read the article

  • Remove margin between rows of overflowing inline elements

    - by Ian
    I'm creating a tile-based game and am using block rendering to update a large list of tiles. I'm attempting to do this in the most simple manner, so I've been trying to work with HTML's default layouts. Right now I'm creating 'inline-blocks', omitting whitespace between the elements to avoid horizontal spaces in between them but when the blocks overflow and create a new line there is some vertical margining in which I do not know how to remove. Example to make this a bit clearer: http://jsfiddle.net/mLa93/13/ (Pretty much I just need to remove the spacing between the block rows while retaining the simple markup.)

    Read the article

  • How to double the size of 8x8 Grid whilst keeping the relative position of certain tiles intact?

    - by ke3pup
    Hi guys I have grid size of size 8x8 , total of 64 Tiles. i'm using this Grid to implement java search algorithms such as BFS and DFS. The Grid has given forbidden Tiles (meaning they can't be traversed or be neighbour of any other tile) and Goal and Start tile. for example Tile 19,20,21,22 and 35, 39 are forbidden and 14 an 43 are the Goal and start node when the program runs. My question is , How can i double the size of the grid, to 16x16 whilst keeping the Relative position of forbidden tiles as well as the Relative position of start and goal Tiles intact? On paper i know i can do this by adding 4 rows and columns to all size but in coding terms i don't know how to make it work? Can someone please give any sort of hints?

    Read the article

  • problem with a very simple tile based game

    - by newbieguy
    Hello, I am trying to create a pacman-like game. I have an array that looks like this: array: 1111111111111 1000000000001 1111110111111 1000000000001 1111111111111 1 = Wall, 0 = Empty space I use this array to draw tiles that are 16x16 in size. The Game character is 32x32. Initially I represented the character's position in array indexes, [1,1] etc. I would update his position if array[character.new_y][charater.new_x] == 0 Then I translated these array coordinates to pixels, [y*16, x*16] to draw him. He was lining up nicely, wouldn't go into walls, but I noticed that since I was updating him by 16 pixels each, he was moving very fast. I decided to do it in reverse, to store the game character's position in pixels instead, so that he could use less than 16 pixels per move. I thought that a simple if statement such as this: if array[(character.new_pixel_y)/16][(character.new_pixel_x)/16] == 0 would prevent him from going into walls, but unfortunately he eats a bit of the bottom and right side walls. Any ideas how would I properly translate pixel position to the array indexes? I guess this is something simple, but I really can't figure it out :(

    Read the article

  • How do I tile and overlay images in WPF?

    - by imnlfn
    I'm very new to WPF and trying to port an application from VB6 to C# and XAML. What I need to do now is create one big image out of a number of small ones, arranged like a series of "tiles." Some of these smaller ones will have overlays superimposed on them. In VB6, accomplishing both the tiling and overlaying would simply be a matter of using the PaintPicture method with the PictureBox control. This is my attempt at the tiling and overlaying in one step (though really the overlaying could occur beforehand): ImageDrawing Drawing1 = new ImageDrawing(new BitmapImage(new Uri(@"c:\one.bmp", UriKind.Absolute)), new Rect(0, 0, 40, 130)); ImageDrawing Drawing2 = new ImageDrawing(new BitmapImage(new Uri(@"c:\two.bmp", UriKind.Absolute)), new Rect(40, 0, 45, 130)); ImageDrawing Drawing3 = new ImageDrawing(new BitmapImage(new Uri(@"c:\overlay.bmp", UriKind.Absolute)), new Rect(40, 0, 45, 130)); DrawingGroup myDrawingGroup = new DrawingGroup(); myDrawingGroup.Children.Add(Drawing1); myDrawingGroup.Children.Add(Drawing2); myDrawingGroup.Children.Add(Drawing3); myImage.Source = new DrawingImage(myDrawingGroup); The tiling works fine, but the overlay is a no-go. I was wondering if someone could point me towards a means of accomplishing the overlays and someone could indicate whether this is the best way to do the tiling. Thanks!!

    Read the article

  • Efficiency of iterators and alternatives? [migrated]

    - by user48037
    I have the following code for my game tiles: std::vector<GameObject_Tile*>::iterator it; for(int y = 0; y < GAME_TILES_Y; y++) { for(int x = 0; x < GAME_TILES_X; x++) { for (it = gameTiles[x][y].tiles.begin() ; it != gameTiles[x][y].tiles.end(); ++it) {}}} tiles is: struct Game_Tile { // More specific object types will be added here eventually vector<GameObject_Tile*> tiles; }; My problem is that if I change the vector to just be a single GameObject_Tile* instead and remove the iterator line in the loop I go from about 200fps to 450fps. Some context: The vector/pointer only contains one object in both scenarios. I will eventually need to store multiple, but for testing I just set it to a single pointer. The loop goes through 2,300 objects each frame and draws them. I would like to point out that if I remove the Draw (not seen int he example) method, I gain about 30 frames in both scenarios, the issue is the iteration. So I am wondering why having this as a vector being looped through by an iterator (to get at a single object) is costing me over 200 frames when compared to it being a single pointer? The 200+ frames faster code is: std::vector<GameObject_Tile*>::iterator it; for(int y = 0; y < GAME_TILES_Y; y++) { for(int x = 0; x < GAME_TILES_X; x++) { //gameTiles[x][y].tiles is used as a pointer here instead of using *it }} tiles is: struct Game_Tile { // More specific object types will be added here eventually GameObject_Tile* tiles; };

    Read the article

  • When mapping the surface of a sphere with tiles, how might you deal with polar distortion?

    - by clweeks
    It's easy to deal with the way locations interact on a clean Cartesian grid. It's just vanilla math. And you can kind of ignore the geometry of the sphere's surface for a bunch of it if you want to just truncate the poles or something. But I keep coming up with ideas for games where the polar space matters. Geo-coded ARGs and global roguelikes and stuff. I want square(ish?) locations -- reasonably representable by square tiles of the same size across the globe, anyway. This has to be a solved problem, right? What are the solutions? ETA: At the equator -- and assuming that your square locations are reasonably small, it's close enough to true that you can get away with having one square in the rows north and south of the most equatorial row. And you could probably get away with that by just hand-waving the difference up to like 45-degrees or so. But eventually, you need to have fewer squares in a pole-ward circumferential row. If I reduce the length of the row by one and offset the squares by 1/2 then they're just like hexes and it's relatively easy to do the coding to keep track of the connections. But as you get pole-ward, it gets more and more extreme. Projecting the surface of the world onto the surface of a cube is tempting. But I figured there must be more elegant solutions already in use. If I did the cube thing (not dissecting it further through geodesy) Are there any pros and cons related to placing the pole at the center of a face or at the vertex of three sides?

    Read the article

  • Finding which tiles are intersected by a line, without looping through all of them or skipping any

    - by JustSuds
    I've been staring at this problem for a few days now. I rigged up this graphic to help me visualise the issue: http://i.stack.imgur.com/HxyP9.png (from the graph, we know that the line intersects [1, 1], [1, 2], [2, 2], [2, 3], ending in [3,3]) I want to step along the line to each grid space and check to see if the material of the grid space is solid. I feel like I already know the math involved, but I haven't been able to string it together yet. I'm using this to test line of sight and eliminate nodes after a path is found via my pathfinding algorithms - my agents cant see through a solid block, therefore they cant move through one, therefore the node is not eliminated from the path because it is required to navigate a corner. So, I need an algorithm that will step along the line to each grid space that it intersects. Any ideas? I've taken a look at a lot of common algorithms, like Bresenham's, and one that steps at predefined intervals along the line (unfortunately, this method skips tiles if they're intersecting with a smaller wedge than the step size). I'm populating my whiteboard now with a mass of floor() and ceil() functions - but its getting overly complicated and I'm afraid it might cause a slowdown.

    Read the article

  • Tiling rectangles seamlessly in WPF

    - by Joe White
    I want to seamlessly tile a bunch of different-colored Rectangles in WPF. That is, I want to put a bunch of rectangles edge-to-edge, and not have gaps between them. If everything is aligned to pixels, this works fine. But I also want to support arbitrary zoom, and ideally, I don't want to use SnapsToDevicePixels (because it would compromise quality when the image is zoomed way out). But that means my Rectangles sometimes render with gaps. For example: <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Background="Black"> <Canvas SnapsToDevicePixels="False"> <Canvas.RenderTransform> <ScaleTransform ScaleX="0.5" ScaleY="0.5"/> </Canvas.RenderTransform> <Rectangle Canvas.Left="25" Width="100" Height="100" Fill="#CFC"/> <Rectangle Canvas.Left="125" Width="100" Height="100" Fill="#CCF"/> </Canvas> </Page> If the ScaleTransform's ScaleX is 1, then the Rectangles fit together seamlessly. When it's 0.5, there's a dark gray streak between them. I understand why -- the combined semi-transparent edge pixels don't combine to be 100% opaque. But I would like a way to fix it. I could always just make the Rectangles overlap, but I won't always know in advance what patterns they'll be in (this is for a game that will eventually support a map editor). Besides, this would cause artifacts around the overlap area when things were zoomed way in (unless I did bevel-cut angles on the underlapping portion, which is an awful lot of work, and still causes problems at corners). Is there some way I can combine these Rectangles into a single combined "shape" that does render without internal gaps? I've played around with GeometryDrawing, which does exactly that, but then I don't see a way to paint each RectangleGeometry with a different-colored brush. Are there any other ways to get shapes to tile seamlessly under an arbitrary transform, without resorting to SnapsToDevicePixels?

    Read the article

  • Tile map collision detection

    - by hero
    There are many topics like this, but none with concrete answers. I am drawing a tile-map in the traditional way (two for loops) and keeping my player centered except when the edges of the map is reached. How would I create collision detection? I need to know how to translate tile location in the array to screen coordinates I think.

    Read the article

  • Tile Collision Question

    - by Alu
    Hey guys, I'm working on tile collision. Currently, I just draw the tile map the normal way (two for loops) and there is no scrolling. Right now, to check if my player is over a tile, I use tileX = (int)person1v.X / 16; tileY = (int)person1v.Y / 16; However, I want to detect collision before I hit the tile so it could act as a wall. How do I detect collision before even making the move?

    Read the article

  • certain BitMapData types dont work in a beginBitmapFill() method.

    - by numerical25
    Say I loaded a bitMap into a bitmapData type called tileImage. tileImage = Bitmap(loader.content).bitmapData; say I decided to add that bitmap into a sprite like below this.graphics.beginBitmapFill(tileImage ); this.graphics.drawRect(0, 0,tWidth ,tHeight ); It would of course work. But say If I decided to add tileImage into a another bitMapData type like below var tImage:BitmapData = new BitmapData(30,30); tImage.copyPixels(tileImage,tRect,tPoint); and I then added tImage to my sprite this.graphics.beginBitmapFill(tImage); this.graphics.drawRect(0, 0,tWidth ,tHeight ); I then get the following error ArgumentError: Error #2015: Invalid BitmapData. tRect and tPoint are all predefined and set. tRect x and y are 0,0 and the width and height are 30x30. tPoint is 0,0 as well. Yes I understand that this is a very brief explanation but I wanted to elaborate that a bitMapdata type that has its data from the copypixel method does not work with beginBitmapFill. but a varible that gets its data straigt from the source, does. One works, and one doesnt, yet they are both the same data types. why is this ?

    Read the article

  • Good ways to map a 2D side shooter (somewhat like liero, or soldat)

    - by Blaze
    I'm wondering what way would be best to render a 2D map for a shooter (these will be static maps) similar to Soldat. Multiple options I've considered are a tile based map (stored in txt files), or just creating different classes for the different terrains I plan to use and creating a data structure to read/store them in a file. (I want to also be able to include things like jumping/running on walls, sliding down walls/slopes ect) I feel like there must be a better way than either of these, but haven't been able to find definitive information :/ Thanks :)

    Read the article

  • Tile Engine: Entity location wrong

    - by Trizicus
    I've made a tile engine that has 30px by 30px. I've ran into a problem with an object for example. I've loaded an object 20px by 20px and when I do a collision check I have to use x/y position which is top left in Java2D. How can I do collision detection based on the entire object? This is relevant code: boolean checkCol() { int currentGridX = ship.getX()/30; int currentGridY = ship.getY()/30; if(test[currentGridX][currentGridY] == 0) return true; System.out.println("collision"); return false; }

    Read the article

  • Tiling rectangles seamlessly in WPF while maintaing subpixel accuracy?

    - by Jens
    I have had the problem described in the question Tiling rectangles seamlessly in WPF, but am not really happy with the answers given there. I am painting a bar chart by painting lots of rectangles right next to each other. Depending on the scale of the canvas containing them, there are small gaps visible between some of them as a result from sub-pixel rendering. I learned from the above question how to make my rectangles fit with the screen pixels, removing that effect. Unfortunately, my chart may display way more bars than there are pixels. Apart from the tiny gaps (which manifest as a periodic change in color saturation), this works well. If I snap each bar with the screen pixels, most of the bars vanish, though, so I am looking for another solution. Thanks in advance!

    Read the article

  • WHY HAVE YOU ROMOVED MY POST? [closed]

    - by Eddy Freeman
    I posted a question about how to rotate a tile in BufferedImage. I did it in the morning and you removed it. Why have you removed it again? What is wrong with the posts? Tell me before i become angry. You have removed the post twice without informing/telling me the problem. with the posts What is wrong? Tell me. Reply to this post and tell me what is wrong.

    Read the article

  • 2D Engine scrolling on OpenGL via hardware?

    - by drudru
    hi, I'm using OpenGL as the bottom end for a 2D tiling engine. When everything is 2D, it is simple to optimize certain issues. For example, scrolling. If I know a certain section of the screen needs to scroll off the bottom, then I can just blit over that portion. I'm evening moving more than 1 pixel at a time. Without explicit hardware support (think old nintendo hw), this requires a lot of pixel writes. An on chip bitblt would be the next best thing. Essentially, I'm looking at how I can optimize my GL calls to use VRAM texture renders as efficient hardware blits. Is it possible to have GL scroll the framebuffer, or should I just resign myself to double-buffering and re-rendering an entire scene for each frame? Thx

    Read the article

  • tiled images in swing

    - by sasquatch90
    I have task to prepare two windows with swing. One contains grid of squares, with random numbers in them. In second I need to load pieces of tiled image and then show them in the correct order, forming tiled image. Windows should look like this : http://img535.imageshack.us/img535/3129/lab8a.jpg Okay so how to bite this ? I've used swing only few times to draw some 2d polylines, so basically I just theoretically now what to do. Ok, so window number 1: I start with creating Jframe for the window. Then I do for loop and in it create 16 JLabels with random numbers in them ? How to set margins between each tile and the whole window ? Window number 2 : So I start the same, but instead of loading numbers I add images ? Now, how can I load image from file and then set it as background ?

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >