• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Bikonja

Members
  • Content count

    7
  • Joined

  • Last visited

Community Reputation

134 Neutral

About Bikonja

  • Rank
    Newbie

Personal Information

  1. Thanks for the math! However it's not working. It selectes only the tile that would be 0,0 in the original system (the non rotated, top view) and it does so for about width/2 to the left and height/2 above. This made me realize though that I failed to mention my coordinate system (XNA) has it's (0,0) at the top left, not the bottom left of the window. Yesterday I've tried thinking up some formulas, but to no avail. I was sure this would be correct, but it doesn't work for some reason... I'll have to try again after work.. [CODE] x = mX / TileWidth + (mY / TileHeight / 2 - maxX / 2) * TileWidth y = mY / TileHeight + (mX / TileWidth / 2 - maxY / 2) * TileHeight [/CODE] where mX is the mouse X position, offsetted by the X drawing offset mX is the mouse Y position, offsetted by the Y drawing offset maxX is the number of virtual tiles on X axis maxY is the number of virtual tiles on Y axis what virtual tiles means is, the bounding rectangle of a drawn tile, divided by 2, by an axis is in the non-rotated top view, not the isometric view. Ofcourse, it should work only for that virtual tile and then I could use a color map to determine which exact tile is selected, but even without a color map, I can see this does not work.
  2. You need to draw your scene every frame, not just draw it once in it's first state and then update state, but not drawing. Place your drawing code inside the while loop (don't have experience with SDL so can't really say if within SDL_PollEvent while or (!done) while but I would say you should put your drawing code inside the !done while.
  3. @MachinaX What do you mean by "there shouldn't be any maths happening between the x and y mouse coordinates"? What you're saying is this? [CODE] public Point? ScreenToIso(int screenX, int screenY, int tileHeight, int offsetX, int offsetY) { Point? newPoint = null; int nX = -1; int nY = -1; int tX = screenX - offsetX; int tY = screenY - offsetY; nX = Math.Round((double)tX / (double)tileHeight / (double)tileWidth); nX = Math.Round((double)tY / (double)tileHeight / (double)tileWidth); newPoint = new Point(nX, nY); return newPoint; } [/CODE] If this code is what you're saying, then it doesn't work (I mean, after fixing small, insignificant for this, errors like nX being in while Math.Round returns decimal). It selects something way further than under mouse cursor (out of screen). But the code doesn't make sense to me either - why would I divide with tileHeight/tileWidth? I'm also not sure what you mean by the sentence "If the tiles have moved,...", do you mean the -offset I have in tX and tY variables? As for the transparent parts, I'll implement a color map for that, but first I want to get to a stage where the rest actually works. @AticAtac I couldn't get your code to draw properly so I didn't try your picking code. I'm probably missing something, again... But I'm at work now so not much time to play with this. When I get home I'll play around more a bit. Thank you to you both for your contributions.
  4. Hello all, I have a problem with my 2D isometric picking. I've asked on gamedev.stackexchange too, but so far I have no answer. You can read the stackexchange question [url="http://gamedev.stackexchange.com/questions/44834/2d-isometric-picking"]here[/url]. It contains details. I will write a short version here. Here's the code I have for drawing the tiles [CODE] // Draw code int col = 0; int row = 0; for (int i = 0; i < nrOfTiles; ++i) { // XOffset and YOffset are currently hardcoded values, but will represent camera offset combined with HUD offset Point tile = IsoToScreen(col, row, TileWidth / 2, TileHeight / 2, XOffset, YOffset); int x = tile.X; int y = tile.Y; spriteBatch.Draw(_tiles[i], new Rectangle(tile.X, tile.Y, TileWidth, TileHeight), Color.White); col++; if (col >= Columns) // Columns is the number of tiles in a single row { col = 0; row++; } } // Get selection overlay location (removed check if selection exists for simplicity sake) Point tile = IsoToScreen(_selectedTile.X, _selectedTile.Y, TileWidth / 2, TileHeight / 2, XOffset, YOffset); spriteBatch.Draw(_selectionTexture, new Rectangle(tile.X, tile.Y, TileWidth, TileHeight), Color.White); // End of draw code public Point IsoToScreen(int isoX, int isoY, int widthHalf, int heightHalf, int xOffset, int yOffset) { Point newPoint = new Point(); newPoint.X = widthHalf * (isoX + isoY) + xOffset; newPoint.Y = heightHalf * (-isoX + isoY) + yOffset; return newPoint; } [/CODE] And here is the code for getting which tile is the mouse on [CODE] public Point? ScreenToIso(int screenX, int screenY, int tileHeight, int offsetX, int offsetY) { Point? newPoint = null; int nX = -1; int nY = -1; int tX = screenX - offsetX; int tY = screenY - offsetY; nX = -(tY - tX / 2) / tileHeight; nY = (tY + tX / 2) / tileHeight; newPoint = new Point(nX, nY); return newPoint; } [/CODE] This code is close, but not even close enough for a public beta or something like that (even though this is just a proof of concept, which I will later transform into my game). I have no idea why this code is so close. I drew the tiles by thinking up the formula, and by googling I believe I've seen that it is correct (however it's still possible it's not). The code for picking - what ever I came up with, didn't work. What ever I googled, didn't work. This code I currently have is a derivation of something I googled - it was not really close, but closer than others, so I modified it and it's even closer now - I did it by trial and error as I have no idea behaved and behaves the way it did/does. Can anyone point out to me my error? Whenever I think about it, it doesn't make sense to me that it behaves that way. I tried reversing the formula for drawing and it didn't pan out which doesn't make sense either. I must be doing something wrong then so please, if someone sees my error, could you point it out?
  5. Does noone know this? Please, if someone does know this, please try explaining it to me so I understand and therefore can make this code work
  6. I am refreshing this topic since it has already fallen to the second page and no replies yet... Please, if someone knows this stuff, help me understand it!
  7. Hi! I am a begginer in C++ builder, but I have started working on a plugin and I did manage to make some cool functions, but I have GetPixel and SetPixel too, which would be awesome if it weren't so slow... Btw, I am using only WinAPI functions to make the plugin much smaller (from aprox. 50 kb to aprox. 10 kb) so I would like it to stay that way... I was stumped with how to fix this so I asked how to fix this, what to do and I got this answer: HDC hDC, // Handle to the display device context hDCMem; // Handle to the memory device context HBITMAP hBitmap; // Handle to the new bitmap int iWidth, iHeight; // Width and height of the bitmap int iDoneBits; // Changed bits int bitColorARRAY_SIZE; // Size of the array int *bitColorARRAY_PTR; // Pointer to the array with pixels // Retrieve the handle to a display device context for the client // area of the window. hDC = GetDC (hwnd); // Create a memory device context compatible with the device. hDCMem = CreateCompatibleDC (hDC); // Retrieve the width and height of window display elements. iWidth = GetSystemMetrics (SM_CXSCREEN) / 10; iHeight = GetSystemMetrics (SM_CYSCREEN) / 10; // Create a bitmap compatible with the device associated with the // device context. hBitmap = CreateCompatibleBitmap (hDC, iWidth, iHeight); // HERE USE iDoneBits = SetBitmapBits(hBitmap, bitColorARRAY_SIZE, bitColorARRAY_PTR) // HERE USE // Insert code to use the bitmap. // Delete the bitmap object and free all resources associated with it. DeleteObject (hBitmap); // Delete the memory device context and the display device context. DeleteDC (hDCMem); DeleteDC (hDC); I couldn't figure out this code completly... I have tried to implement it, but never succesfully... I understand some parts of the code, while I don't understand others... Some parts I understand, but I don't know how the code should look exactly... So could someone please explain some things to me? Why is iWidth and iHeight /10 and not just the function return value? Where do I use the MemoryDC? What I need to do with it? I know something about the lines need to be aligned and stuff, but I just can't seem to get it from everything I read on the net... So if someone would be please be so kind to try and explain this stuff a bit to me... How would I get a string in format "R,G,B" from an exact pixel... So let's say I want to get the color of the pixel on the screen with coordinates 20,53 and I need to get this in a string like "255,238,13"... How would I set a pixel like that? I am sorry I can't understand this code and I bug you, but for some reason I just can't seem to figure this code out... Thanx!