isometric

convert Cartesian width and height to Isometric

一世执手 提交于 2019-12-12 01:16:16
问题 I'm trying to create an Isometric game in the SDL graphics library. When you render in SDL you require a source rectangle and a destination rectangle. The source rectangle is the portion of the texture you have loaded that you wish to render and the destination rectangle is the area on the screen you are rendering to. Rectangles simply consist of 4 properties, X position, Y position, Width, and Height. Now say I have a Cartesian destination rectangle with these coordinates: X=20, Y=10, Width

Calculating the cells contained inside a rectangle on an Isometric Grid

蹲街弑〆低调 提交于 2019-12-11 07:37:24
问题 Consider that we are given an isometric grid (consider something like Diablo) of tiles. We have some measures for the grid, like grid height, grid width and tile height/width. Consider this image: The center cell of the grid is 0,0 extending iso-north (+y), iso-south(-y), iso-east(+x), iso-west(-x). Let's say we to draw a rectangle at an arbitrary location on the grid. We do NOT have the isometric positions for the rectangle, but rather have the normal draw coordinates for the grid where the

Drawing Isometric Tilemaps

穿精又带淫゛_ 提交于 2019-12-11 01:17:40
问题 I've been working on drawing an isometric map with C# / XNA Game Studio, and while I've gotten pretty far it doesn't look quite right and I was wondering if anybody can help. Here's the code I have for drawing the map: public void Draw(SpriteBatch theBatch, int drawX, int drawY) { if ((drawY % 2 == 0)) theBatch.Draw(tileTexture, new Rectangle((drawX * width), (drawY * length / 2), width, length), Color.White); else theBatch.Draw(tileTexture, new Rectangle(((drawX * width) + (width / 2)),

Render isometric text in 2D

拈花ヽ惹草 提交于 2019-12-10 22:43:23
问题 How can I render text in the form of an isometric projection? I understand the principle but I'm not sure how to actually transform a SpriteFont programmatically to do this. Example of what I mean: I'm not even sure what I should be searching for. It seems I could accomplish this by using an isometric projection matrix and a 3D mesh font, but that seems overcomplicated considering I'm working in 2D. Any ideas? 回答1: SpriteBatch.Begin takes a Matrix parameter, transforming the sprites you draw

Tiled Map Editor: size of isometric tile side

我的未来我决定 提交于 2019-12-09 19:58:20
问题 In Tiled editor there is an isometric map example: "isometric_grass_and_water.tmx". This example shows simple isometric map with tiles which have size 64x32 pixels. I need to know size of the side of a tile, so I simply used Pythagorean theorem for this: In right-angled triangle ABC side AC = width / 2 = 32 and side AB = height / 2 = 16. Thus side of a tile (BC) can be calculated as: So whole tile is a rhombus in which each side = 35.777. However when I add an square object with dimensions 35

Swift Spritekit isometric map touch location

僤鯓⒐⒋嵵緔 提交于 2019-12-09 06:07:50
问题 I've started doing a small swift / spritekit project to teach myself game dev. It starts with an isometric map, which I managed to draw. But I'm having trouble getting a precise touch location on the different tiles of the map. It works, but is slightly out of place, and does not seem consistent. Here are my functions : class PlayScene: SKScene { let map = SKNode() override func didMoveToView(view: SKView) { let origin = view.frame.origin let mapOrigin = CGPointMake(origin.x + self.frame

2D isometric engine - Math problems - Cube selection - diamond shape map

十年热恋 提交于 2019-12-08 09:27:10
问题 I calculate my coordinates when i create a layer with a std::vector , filled with cube objects(wich is a class of mine): for(int J = 0; J < mapSize; J++) { for(int I = 0; I < mapSize; I++) { x = (J - I) * (cubeSize/2); y = (J + I) * (cubeSize/4); c = new cube(cubeSize, x, y, z, I, J); cs.push_back(*c); } } I wanna do this : cs[getCubeByID(mouseX, mouseY)].setTexture(...); Example of use: The cube in I-J [0, 0] have the number 0 in the cubes array. if i click on 0,0 i got this number. EDIT: We

Isometric screen to map issue

无人久伴 提交于 2019-12-08 09:14:33
问题 I know that about isometric map a lot of advice but I've read most of them and didn't solve my problem. I rewrite code for C# for more simplicity (this code will be used on Android platform) I need to get screen cords to isometric coords. Here we go I used 1:2 tiles for me 64x32, I build diamond map using this code private void drawIsoGrid(PaintEventArgs e) { for(int y=0;y<20;y++) for(int x=0;x<20;x++) { float rx = (x - y) * (surface.Width) / 2 - globX; float ry = (x + y) * (surface.Height) /

Click detection in a 2D isometric grid?

不打扰是莪最后的温柔 提交于 2019-12-05 21:32:58
I've been doing web development for years now and I'm slowly getting myself involved with game development and for my current project I've got this isometric map, where I need to use an algorithm to detect which field is being clicked on. This is all in the browser with Javascript by the way. The map It looks like this and I've added some numbers to show you the structure of the fields (tiles) and their IDs. All the fields have a center point (array of x,y) which the four corners are based on when drawn. As you can see it's not a diamond shape, but a zig-zag map and there's no angle (top-down

How to calculate the index of the tile underneath the mouse in an isometric world taking into account tile elevation

≯℡__Kan透↙ 提交于 2019-12-05 03:40:58
I have a tile-based isometric world and I can calculate which tile is underneath specific (mouse) coordinates by using the following calculations: function isoTo2D(pt:Point):Point{ var tempPt:Point = new Point(0, 0); tempPt.x = (2 * pt.y + pt.x) / 2; tempPt.y = (2 * pt.y - pt.x) / 2; return(tempPt); } function getTileCoordinates(pt:Point, tileHeight:Number):Point{ var tempPt:Point = new Point(0, 0); tempPt.x = Math.floor(pt.x / tileHeight); tempPt.y = Math.floor(pt.y / tileHeight); return(tempPt); } (Taken from http://gamedevelopment.tutsplus.com/tutorials/creating-isometric-worlds-a-primer