Search Results

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

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

  • Storing Tiled Level Data in J2ME game

    - by Alex
    I'm developing a J2ME game which uses tiled backgrounds for the levels. My question is how do I store this tile information in my game. At the moment it is stored as an array; with each number representing a different tile from the tile-sheet. This works well enough, however I don't like the fact that it is 'hard-coded' into the game because (at least in my opinion) it is harder to edit the levels, or design new ones. I was also thinking that it would be difficult if you wanted to add a 'level pack', I'm not sure on how this would be achieved though; it's not something I was planning on doing, I'm just curious. I was wondering if there was a way I could store level data in some external file and then load this in to the game. The problem is I don't know what the limitations are for J2ME regarding file I/O, can it read in any file like Java? I am aware of the RMS, but from my experience I don't think this would work (unless I am mistaken). Also, would loading the data in this way be too big a performance hit? Or is there another way I can achieve what I am trying to do. As I said, the way I have it at the moment works fine, and if this is the only viable option then it will suffice.

    Read the article

  • 2D Camera Acceleration/Lag

    - by Cyral
    I have a nice camera set up for my 2D xna game. Im wondering how I should make the camera have 'acceleration' or 'lag' so it smoothly follows the player, instead of 'exactly' like mine does now. Im thinking somehow I need to Lerp the values when I set CameraPosition. Heres my code private void ScrollCamera(Viewport viewport) { float ViewMargin = .35f; float marginWidth = viewport.Width * ViewMargin; float marginLeft = cameraPosition.X + marginWidth; float marginRight = cameraPosition.X + viewport.Width - marginWidth; float TopMargin = .3f; float BottomMargin = .1f; float marginTop = cameraPosition.Y + viewport.Height * TopMargin; float marginBottom = cameraPosition.Y + viewport.Height - viewport.Height * BottomMargin; Vector2 CameraMovement; Vector2 maxCameraPosition; CameraMovement.X = 0.0f; if (Player.Position.X < marginLeft) CameraMovement.X = Player.Position.X - marginLeft; else if (Player.Position.X > marginRight) CameraMovement.X = Player.Position.X - marginRight; maxCameraPosition.X = 16 * Width - viewport.Width; cameraPosition.X = MathHelper.Clamp(cameraPosition.X + CameraMovement.X, 0.0f, maxCameraPosition.X); CameraMovement.Y = 0.0f; if (Player.Position.Y < marginTop) //above the top margin CameraMovement.Y = Player.Position.Y - marginTop; else if (Player.Position.Y > marginBottom) //below the bottom margin CameraMovement.Y = Player.Position.Y - marginBottom; maxCameraPosition.Y = 16 * Height - viewport.Height; cameraPosition.Y = MathHelper.Clamp(cameraPosition.Y + CameraMovement.Y, 0.0f, maxCameraPosition.Y); }

    Read the article

  • Multiplayer tile based movement synchronization

    - by Mars
    I have to synchronize the movement of multiple players over the Internet, and I'm trying to figure out the safest way to do that. The game is tile based, you can only move in 4 directions, and every move moves the sprite 32px (over time of course). Now, if I would simply send this move action to the server, which would broadcast it to all players, while the walk key is kept being pressed down, to keep walking, I have to take this next command, send it to the server, and to all clients, in time, or the movement won't be smooth anymore. I saw this in other games, and it can get ugly pretty quick, even without lag. So I'm wondering if this is even a viable option. This seems like a very good method for single player though, since it's easy, straight forward (, just take the next movement action in time and add it to a list), and you can easily add mouse movement (clicking on some tile), to add a path to a queue, that's walked along. The other thing that came to my mind was sending the information that someone started moving in some direction, and again once he stopped or changed the direction, together with the position, so that the sprite will appear at the correct position, or rather so that the position can be fixed if it's wrong. This should (hopefully) only make problems if someone really is lagging, in which case it's to be expected. For this to work out I'd need some kind of queue though, where incoming direction changes and stuff are saved, so the sprite knows where to go, after the current movement to the next tile is finished. This could actually work, but kinda sounds overcomplicated. Although it might be the only way to do this, without risk of stuttering. If a stop or direction change is received on the client side it's saved in a queue and the char keeps moving to the specified coordinates, before stopping or changing direction. If the new command comes in too late there'll be stuttering as well of course... I'm having a hard time deciding for a method, and I couldn't really find any examples for this yet. My main problem is keeping the tile movement smooth, which is why other topics regarding synchronization of pixel based movement aren't helping too much. What is the "standard" way to do this?

    Read the article

  • Collision Detection Problems

    - by MrPlosion
    So I'm making a 2D tile based game but I can't quite get the collisions working properly. I've taken the code from the Platformer Sample and implemented it into my game as seen below. One problem I'm having is when I'm on the ground for some strange reason I can't move to the left. Now I'm pretty sure this problem is from the HandleCollisions() method because when I stop running it I can smoothly move around with no problems. Another problem I'm having is when I'm close to a tile the character jitters very strangely. I will try to post a video if necessary. Here is the HandleCollisions() method: Thanks. void HandleCollisions() { Rectangle bounds = BoundingRectangle; int topTile = (int)Math.Floor((float)bounds.Top / World.PixelTileSize); int bottomTile = (int)Math.Ceiling((float)bounds.Bottom / World.PixelTileSize) - 1; int leftTile = (int)Math.Floor((float)bounds.Left / World.PixelTileSize); int rightTile = (int)Math.Ceiling((float)bounds.Right / World.PixelTileSize) - 1; isOnGround = false; for(int x = leftTile; x <= rightTile; x++) { for(int y = topTile; y <= bottomTile; y++) { if(world.Map[y, x].Collidable == true) { Rectangle tileBounds = new Rectangle(x * World.PixelTileSize, y * World.PixelTileSize, World.PixelTileSize, World.PixelTileSize); Vector2 depth = RectangleExtensions.GetIntersectionDepth(bounds, tileBounds); if(depth != Vector2.Zero) { if(Math.Abs(depth.Y) < Math.Abs(depth.X)) { isOnGround = true; position = new Vector2(position.X, position.Y + depth.Y); } else { position = new Vector2(position.X + depth.X, position.Y); } bounds = BoundingRectangle; } } } }

    Read the article

  • what would be a good way to implement/render a 2d tiled map for a browser game?

    - by jj_
    I've made this little rpg ruby game I did while learning and now I'd like to make it into a browser game. I've already set up Sinatra framework to serve it, so what I am looking for, before everything else, is a way to represent the game map in browser (location attributes are stored in db). A new map is randomly generated by code for each new game at each game start. For now forget db, and let's say a map (say 100x100 "squares") is stored as a tridimensional array. (x,y, ...) Last "dimension" of array stores who & what is at that map cell: a player, a building, whatever. So all I have to do is render those "squares" or array cells to a 2d tiled map in the browser. The map does not need to refresh or be dynamically fetched as you scroll it, (at least at this stage of development) but, a technology which would allow me to do so in future would be a good reason for choosing it. Things that I thought of: html tables, html5 canvas, some js framework which is designed exactly with this purpose (which I do not know of = please advice). Yes I know about gamequery-js framework, but I've never used it, and I don't know if it's going to slow down everything down to inusability as I'm adding new features (scrolling, ajax). I really don't know of any other alternatives.. maybe there are lighter approaches? Easier or more minimalistic ways ? More targeted js framework which is the right tool for the job? Maybe just some html canvas code, or even simple image maps, or images with absolute positioning will be enough? The thing is I'd like to start simple, and then gradually make it better, so, as I said before, I'd prefer something that will give me room for improvement or is headed toward new web tendencies but which will also give me a bit of gratification in the beginning :) So.. advices are needed! And appreciated! :) Thanks p.s. Flash is excluded because I don't like it.

    Read the article

  • Android "Hello, MapView" Tutorial - Map Tiles Do Not Load

    - by Onyx
    I am new to Android software development and new to this site. I am hoping someone might have some experience with the problem I am having. I've been following the Hello, MapView tutorial in order to not only learn the Android framework, but also the Google Maps library. I've tried my best to implement things exactly as the tutorial has instructed. My problem is that the application does load in my emulator (or even on my phone for that matter), but the map tiles do not load. Searching Google I found a post by someone else on another site having the same issue, but his/her problem was that the important elements added to the AndroidManifest.xml file were not in the right order. I double-checked this in mine, but everything seems to be right. So, I am not sure what the issue is and was hoping others have seen this before. I can provide any snippets of code, if that would help. Thank you.

    Read the article

  • PGU Tiles collision detection

    - by user280454
    Hi, I've been using PGU(Phil's Pygame Utilities) for a while. It has a dictionary called tdata, which is passed as an argument while loading tiles tdata = { tileno:(agroup, hit_handler, config)} I'm making a pacman clone in which I have 2 groups : player and ghost, for which I want to collision detection with the same type of tile. For example, if the tile no is 2, I want this tile to have agroups as both player and ghost. I tried doing the following: tdata = {0x02 :('player', tile_hit_1, config), 0x02 : ('ghost', tile_hit_2, config)} However, on doing this, it only gives collision detection for ghost, not the player. Any ideas on how I can do collision detection for both the player and the ghost with the same type of tile?

    Read the article

  • Plot hex tiles with different length sides?

    - by Phil
    I'm trying to create a basic grid of hex tiles. I found some code... s=h/Math.cos(30*Math.PI/180)/2; tile._x=x*s*1.5; tile._y=y*h+(x%2)*h/2; That does just that, but I think it's setup for hex's that have same length sides. However my hex has different length sides. It's width is 140 and it's height is 80. I could completely change the code to work with my side lengths, but I was wondering if there's a better way of doing it with the code above.

    Read the article

  • Efficiently Reshaping/Reordering Numpy Array to Properly Ordered Tiles (Image)

    - by Phelix
    I would like to be able to somehow reorder a numpy array for efficient processing of tiles. what I got: >>> A = np.array([[1,2],[3,4]]).repeat(2,0).repeat(2,1) >>> A # image like array array([[[1, 1, 2, 2], [1, 1, 2, 2]], [[3, 3, 4, 4], [3, 3, 4, 4]]]) >>> A.reshape(2,2,4) array([[[1, 1, 2, 2], [1, 1, 2, 2]], [[3, 3, 4, 4], [3, 3, 4, 4]]]) what I want: X >>> X array([[[1, 1, 1, 1], [2, 2, 2, 2]], [[3, 3, 3, 3], [4, 4, 4, 4]]]) to be able to do something like: >>> X[X.sum(2)>12] -= 1 >>> X array([[[1, 1, 1, 1], [2, 2, 2, 2]], [[3, 3, 3, 3], [3, 3, 3, 3]]]) Is this possible without a slow python loop? Bonus: Conversion back from X to A Edit: How can I get X from A?

    Read the article

  • How can I implement collision detection for these tiles?

    - by Fiona
    I am wondering how this would be possible, if at all. In the image below: http://i.stack.imgur.com/d8cO3.png The light brows tiles are ground, while the dark brown is background, so the player can pass over those tiles. Here's the for loops that draws the level: float scale = 1f; for (row = 0; row < currentLevel.Rows; row++) { for (column = 0; column < currentLevel.Columns; column++) { Tile tile = (Tile)currentLevel.GetTile(row, column); if (tile == null) { continue; } Texture2D texture = tile.Texture; spriteBatch.Draw(texture, new Microsoft.Xna.Framework.Rectangle( (int)(column * currentLevel.CellSize.X * scale), (int)(row * currentLevel.CellSize.Y * scale), (int)(currentLevel.CellSize.X * scale), (int)(currentLevel.CellSize.Y * scale)), Microsoft.Xna.Framework.Color.White); } } Here's what I have so far to determine where to create a Rectangle: Microsoft.Xna.Framework.Rectangle[,,,] groundBounds = new Microsoft.Xna.Framework.Rectangle[?, ?, ?, ?]; int tileSize = 20; int screenSizeInTiles = 30; var tilePositions = new System.Drawing.Point[screenSizeInTiles, screenSizeInTiles]; for (int x = 0; x < screenSizeInTiles; x++) { for (int y = 0; y < screenSizeInTiles; y++) { tilePositions[x, y] = new System.Drawing.Point(x * tileSize, y * tileSize); groundBounds[x, y, tileSize, tileSize] = new Microsoft.Xna.Framework.Rectangle(x, y, 20, 20); } } First off, I'm not sure how to initialize the array groundBounds (I don't know how big to make it). Also, I'm not entirely sure how to go about adding information to groundBounds. I want to add a Rectangle for each tile in the level. Preferably I'd only make a Rectangle for those tiles accessible by the player, and not background tiles, but that's for a different day. FYI, the map was made with a freeware program called Realm Factory.

    Read the article

  • How to tile a 30000 x 6000 image for a 480 x 320 screen?

    - by Horace Ho
    (this is related to another question about implementation on iPhone) I have a large image, size around 30000 (w) x 6000 (h) pixels. You may consider it's like a big map. I assume I need to crop it up into smaller tiles. Questions: what is the tile strategy? Requirements: whole image (though cropped) can be scrolled up/down/left/right by swipes zoom in (up to pixel-to-pixel) out (down to screen-fit-by-height) by the 2-finger operation memory efficiency by lazy loading tiles Thanks!

    Read the article

  • opengl, Black lines in-between tiles

    - by MiJyn
    When its translated in an integral value (1,2,3, etc....), there are no black lines in-between the tiles, it looks fine. But when it's translated to a non-integral (1.1, 1.5, 1.67), there are small blackish lines between each tile (I'm imagining that it's due to subpixel rendering, right?) ... and it doesn't look pretty =P So... what should I do? This is my image-loading code, by the way: bool Image::load_opengl() { this->id = 0; glGenTextures(1, &this->id); this->bind(); // Parameters... TODO: Should we change this? glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, this->size.x, this->size.y, 0, GL_BGRA, GL_UNSIGNED_BYTE, (void*) FreeImage_GetBits(this->data)); this->unbind(); return true; } I've also tried using: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); and: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); Here is my image drawing code: void Image::draw(Pos pos, CROP crop, SCALE scale) { if (!this->loaded || this->id == 0) { return; } // Start position & size Pos s_p; Pos s_s; // End size Pos e_s; if (crop.active) { s_p = crop.pos / this->size; s_s = crop.size / this->size; //debug("%f %f", s_s.x, s_s.y); s_s = s_s + s_p; s_s.clamp(1); //debug("%f %f", s_s.x, s_s.y); } else { s_s = 1; } if (scale.active) { e_s = scale.size; } else if (crop.active) { e_s = crop.size; } else { e_s = this->size; } // FIXME: Is this okay? s_p.y = 1 - s_p.y; s_s.y = 1 - s_s.y; // TODO: Make this use VAO/VBO's!! glPushMatrix(); glTranslate(pos.x, pos.y, 0); this->bind(); glBegin(GL_QUADS); glTexCoord2(s_p.x, s_p.y); glVertex2(0, 0); glTexCoord2(s_s.x, s_p.y); glVertex2(e_s.x, 0); glTexCoord2(s_s.x, s_s.y); glVertex2(e_s.x, e_s.y); glTexCoord2(s_p.x, s_s.y); glVertex2(0, e_s.y); glEnd(); this->unbind(); glPopMatrix(); } OpenGL Initialization code: void game__gl_init() { glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0.0, config.window.size.x, config.window.size.y, 0.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } Screenshots of the issue:

    Read the article

  • How can I author objects with perspective that fit into a tile-based map but span multiple tiles?

    - by Growler
    I'm creating a tilemap city and trying to figure out the most efficient way to create unique building scenes. The trick is, I need to maintain a sort of 2D, almost-top-down perspective, which is hard to do with buildings or large objects that span multiple tiles. I've tried doing three buildings at a time, and mixing and matching the base layer and colors, like this: This creates a weird overlapping effect, and also doesn't seem that efficient from a production standpoint. But it was the best way to have shadows appear correctly on the neighboring buildings. I'm wondering if modular buildings would be the way to go? That way I can mix and match any set of buildings together as tiles: I guess I would have to risk some perspective and shadowing to get the buildings to align correctly. What sort of authoring process could I use to allow me to create a variety of buildings (or other objects) that maintain this perspective while spanning multiple tiles worth of screen space? Would you recommend creating blank buildings, and then affixing art overlays as necessary to make the buildings unique? Or should they be directly part of the building tile (for example, create a separate tileset of buildings signs and colorings)?

    Read the article

  • How do I cap rendering of tiles in a 2D game with SDL?

    - by farmdve
    I have some boilerplate code working, I basically have a tile based map composed of just 3 colors, and some walls and render with SDL. The tiles are in a bmp file, but each tile inside it corresponds to an internal number of the type of tile(color, or wall). I have pretty basic collision detection and it works, I can also detetc continuous presses, which allows me to move pretty much anywhere I want. I also have a moving camera, which follows the object. The problem is that, the tile based map is bigger than the resolution, thus not all of the map can be displayed on the screen, but it's still rendered. I would like to cap it, but since this is new to me, I pretty much have no idea. Although I cannot post all the code, as even though I am a newbie and the code pretty basic, it's already quite a few lines, I can post what I tried to do void set_camera() { //Center the camera over the dot camera.x = ( player.box.x + DOT_WIDTH / 2 ) - SCREEN_WIDTH / 2; camera.y = ( player.box.y + DOT_HEIGHT / 2 ) - SCREEN_HEIGHT / 2; //Keep the camera in bounds. if(camera.x < 0 ) { camera.x = 0; } if(camera.y < 0 ) { camera.y = 0; } if(camera.x > LEVEL_WIDTH - camera.w ) { camera.x = LEVEL_WIDTH - camera.w; } if(camera.y > LEVEL_HEIGHT - camera.h ) { camera.y = LEVEL_HEIGHT - camera.h; } } set_camera() is the function which calculates the camera position based on the player's positions. I won't pretend I know much about it. Rectangle box = {0,0,0,0}; for(int t = 0; t < TOTAL_TILES; t++) { if(box.x < (camera.x - TILE_WIDTH) || box.y > (camera.y - TILE_HEIGHT)) apply_surface(box.x - camera.x, box.y - camera.y, surface, screen, &clips[tiles[t]]); box.x += TILE_WIDTH; //If we've gone too far if(box.x >= LEVEL_WIDTH) { //Move back box.x = 0; //Move to the next row box.y += TILE_HEIGHT; } } This is basically my render code. The for loop loops over 192 tiles stored in an int array, each with their own unique value describing the tile type(wall or one of three possible colored tiles). box is an SDL_Rect containing the current position of the tile, which is calculated on render. TILE_HEIGHT and TILE_WIDTH are of value 80. So the cap is determined by if(box.x < (camera.x - TILE_WIDTH) || box.y > (camera.y - TILE_HEIGHT)) However, this is just me playing with the values and see what doesn't break it. I pretty much have no idea how to calculate it. My screen resolution is 1024/768, and the tile map is of size 1280/960.

    Read the article

  • How to scroll and zoom in/out large images on iPhone?

    - by Horace Ho
    I have a large image, size around 30000 (w) x 6000 (h) pixels. You may consider it's like a big map. I assume I need to crop it up into smaller tiles. Questions: what are the right ViewControllers to use? (link) what is the tile strategy? (I put this in another question, as it's not iPhone specific) Requirements: whole image (though cropped) can be scrolled up/down/left/right by swipes zoom in (up to pixel-to-pixel) out (down to screen-fit-by-height) by the 2-finger operation memory efficiency by lazy loading tiles Bonus requirements: automatic scroll, say from left to right slowly and smoothly Thanks!

    Read the article

  • Pure HTML + JavaScript client side templating

    - by Dev er dev
    I want to have achieve something similar to Java Tiles framework using only client side technologies (no server side includes). I would like to have one page, eg layout.html which will contain layout definition. Content placeholder in that page would be empty #content div tag. I would like to have different content injected on that page based on url. Something like layout.html?content=main or layout.html?content=edit will display page with content replaced with main.html or edit.html. The goal is to avoid duplicating code, even for layout, and to compose pages without server-side templating. What approach would you suggest? EDIT: I don't need a full templating library, just a way to compose a pages, similar for what tiles do.

    Read the article

  • display custome tile for missing tiles in google maps app

    - by Beans
    I am working with google maps in flash, and i would like to know how to serve up my own image tile for the "we have no imagery at this zoom level..." error. I dont want to serve up an entire map of images - just for the times when google has no image does the tile layer base dispatch an event? (i couldnt find any in the api) is there a method that can be overridden by extending the tilelayerbase class any help appreciated

    Read the article

  • How to send exceptions to exceptionController?

    - by ivar
    <bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"> <property name="mappedHandlers"> <set> <ref bean="exceptionController" /> </set> </property> <property name="defaultErrorView" value="tiles/content/error" /> </bean> I'm trying to send exceptions to a controller so I can create a redirect. If I comment out the mappedHandlers part then the error tile is displayed but it is only a tile. The rest of the tiles load normally. I need to make a redirect in the controller so I can show an error page not just an error tile. I can't find enough information or an example how the exception invokes some method in exceptionController.

    Read the article

  • "Find all tiles connected to this one" project

    - by Omega
    Remember MS Paint? The bucket tool? If you used it and clicked on a pixel, all pixels connected to this pixel that are the same are affected. The theory is, I suppose, to check if there is any pixel adjacent to the selected one. If such pixel is the same type as the selected one, check for more adjacent pixels in this one, and so on. I want to implement something similar in VB.NET. Basically I have a 2D array map which represents the map. Let's assume there are only two types of tile: 0 and 1. Now, I got pretty much everything ready: I got my 2d map and I can tell which tile is clicked and tell what array indexes are the ones that represent such tile. Now for the "painting" process. Whenever I think about it, I can't figure a convenient way to execute such iteration. Can someone help me choosing a correct design/way/tip to achieve this?

    Read the article

  • How to do reflective collisions with particles hitting background tiles?

    - by Shawn LeBlanc
    In my 2d pixel old-school platformer, I'm looking for methods for bouncing particles off of background tiles. Particles aren't affected by gravity and collisions are "reflective". By that I mean a particle hitting the side of a square tile at 45 degrees should bounce off at 45 degrees as well. We can assume that tiles will always be perfectly square. No slopes or anything. What are efficient methods and algorithms to do this? I'd be implementing this on a Sega Genesis.

    Read the article

  • Self-describing file format for gigapixel images?

    - by Adam Goode
    In medical imaging, there appears to be two ways of storing huge gigapixel images: Use lots of JPEG images (either packed into files or individually) and cook up some bizarre index format to describe what goes where. Tack on some metadata in some other format. Use TIFF's tile and multi-image support to cleanly store the images as a single file, and provide downsampled versions for zooming speed. Then abuse various TIFF tags to store metadata in non-standard ways. Also, store tiles with overlapping boundaries that must be individually translated later. In both cases, the reader must understand the format well enough to understand how to draw things and read the metadata. Is there a better way to store these images? Is TIFF (or BigTIFF) still the right format for this? Does XMP solve the problem of metadata? The main issues are: Storing images in a way that allows for rapid random access (tiling) Storing downsampled images for rapid zooming (pyramid) Handling cases where tiles are overlapping or sparse (scanners often work by moving a camera over a slide in 2D and capturing only where there is something to image) Storing important metadata, including associated images like a slide's label and thumbnail Support for lossy storage What kind of (hopefully non-proprietary) formats do people use to store large aerial photographs or maps? These images have similar properties.

    Read the article

  • Not showing error when calling another function in Spring

    - by Javi
    Hello, I have a controller with 2 methods. The first one just add some lists to the model (the lists of my comboboxes) and return a JSP with a form. The second one validates the data and if there aren't errors it saves the data. The code looks like this: public String showForm(Model model){ //load some data into some lists return "tiles:myJSPfile"; } public String save(@Valid @ModelAttribute("MyData") Data data, BindingResult result, Model model){ if(result.hasErrors()){ //there are errors: show form with error messages //(but I need to reload the combobox lists) return showForm(model); } //save data } The problem is that in this way I don't see the error messages in the form (though I see by the debugger that it has found errors). I've thought that the problem comes because the showForm method doesn't have the error messages because it can't see the BindingResult, so I've added BindingResult as a parameter of showForm method, but it still doesn't work. I've added My Model Attribute as well but I get the same problem. If I just return the JSP file in the save method I can see the errors, but in this way I would need to add again in this other method the lists I had already added in the showForm (duplicated code). I can't save the data in session scope so it's compulsory to get again the lists after getting the error. if(result.hasErrors()){ //there are errors: show form with error messages return "tiles:myJSPfile"; } Why are errors not shown when I call a function to display my JSP different from the one I used for the validation? What's the best way to do this? Thanks.

    Read the article

  • Managing text-maps in a 2D array on to be painted on HTML5 Canvas

    - by weka
    So, I'm making a HTML5 RPG just for fun. The map is a <canvas> (512px width, 352px height | 16 tiles across, 11 tiles top to bottom). I want to know if there's a more efficient way to paint the <canvas>. Here's how I have it right now. How tiles are loaded and painted on map The map is being painted by tiles (32x32) using the Image() piece. The image files are loaded through a simple for loop and put into an array called tiles[] to be PAINTED on using drawImage(). First, we load the tiles... and here's how it's being done: // SET UP THE & DRAW THE MAP TILES tiles = []; var loadedImagesCount = 0; for (x = 0; x <= NUM_OF_TILES; x++) { var imageObj = new Image(); // new instance for each image imageObj.src = "js/tiles/t" + x + ".png"; imageObj.onload = function () { console.log("Added tile ... " + loadedImagesCount); loadedImagesCount++; if (loadedImagesCount == NUM_OF_TILES) { // Onces all tiles are loaded ... // We paint the map for (y = 0; y <= 15; y++) { for (x = 0; x <= 10; x++) { theX = x * 32; theY = y * 32; context.drawImage(tiles[5], theY, theX, 32, 32); } } } }; tiles.push(imageObj); } Naturally, when a player starts a game it loads the map they last left off. But for here, it an all-grass map. Right now, the maps use 2D arrays. Here's an example map. [[4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 1, 1, 1, 1], [1, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 1], [13, 13, 13, 13, 1, 1, 1, 1, 13, 13, 13, 13, 13, 13, 13, 1], [13, 13, 13, 13, 1, 13, 13, 1, 13, 13, 13, 13, 13, 13, 13, 1], [13, 13, 13, 13, 1, 13, 13, 1, 13, 13, 13, 13, 13, 13, 13, 1], [13, 13, 13, 13, 1, 13, 13, 1, 13, 13, 13, 13, 13, 13, 13, 1], [13, 13, 13, 13, 1, 1, 1, 1, 13, 13, 13, 13, 13, 13, 13, 1], [13, 13, 13, 13, 13, 13, 13, 1, 13, 13, 13, 13, 13, 13, 13, 1], [13, 13, 13, 13, 13, 11, 11, 11, 13, 13, 13, 13, 13, 13, 13, 1], [13, 13, 13, 1, 1, 1, 1, 1, 1, 1, 13, 13, 13, 13, 13, 1], [1, 1, 1, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 1, 1, 1]]; I get different maps using a simple if structure. Once the 2d array above is return, the corresponding number in each array will be painted according to Image() stored inside tile[]. Then drawImage() will occur and paint according to the x and y and times it by 32 to paint on the correct x-y coordinate. How multiple map switching occurs With my game, maps have five things to keep track of: currentID, leftID, rightID, upID, and bottomID. currentID: The current ID of the map you are on. leftID: What ID of currentID to load when you exit on the left of current map. rightID: What ID of currentID to load when you exit on the right of current map. downID: What ID of currentID to load when you exit on the bottom of current map. upID: What ID of currentID to load when you exit on the top of current map. Something to note: If either leftID, rightID, upID, or bottomID are NOT specific, that means they are a 0. That means they cannot leave that side of the map. It is merely an invisible blockade. So, once a person exits a side of the map, depending on where they exited... for example if they exited on the bottom, bottomID will the number of the map to load and thus be painted on the map. Here's a representational .GIF to help you better visualize: As you can see, sooner or later, with many maps I will be dealing with many IDs. And that can possibly get a little confusing and hectic. The obvious pros is that it load 176 tiles at a time, refresh a small 512x352 canvas, and handles one map at time. The con is that the MAP ids, when dealing with many maps, may get confusing at times. My question Is this an efficient way to store maps (given the usage of tiles), or is there a better way to handle maps? I was thinking along the lines of a giant map. The map-size is big and it's all one 2D array. The viewport, however, is still 512x352 pixels. Here's another .gif I made (for this question) to help visualize: Sorry if you cannot understand my English. Please ask anything you have trouble understanding. Hopefully, I made it clear. Thanks.

    Read the article

  • JXMapViewer change orientation to Heading Up

    - by Charlie
    I am trying to use JXMapViewer (from swingx-ws) with Open Street Maps. I was wondering if it would be possible to display the map tiles in the JXMapViewer based on heading up, rather than on North up. For example, the normal car GPS navigation systems let you do that. I've looked through the documentation and there doesn't seem to be a straightforward way to do this. Is there something else that accomplish this, besides JXMapViewer?

    Read the article

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