Tile Based RPG layering problems

Hello,
I'm having trouble making certain parts of an image go behind other images. There is an overlay image that is positioned on a tile and it covers about half of the tile above it. When i move my character to the tile above the overlay, the character is above the overlay image and not behind it. How do i make the pixels of the character image not show if the character moves behind the overlay.
Thanks,
Bluelikeu

Also, characters closer to the front of the world (from the player's perspective), need to be drawn after characters farther back. Same principle.
(Actually, there is a way you can avoid drawing overlapping pixels, but I'd recommend implementing this method before you try out something more complex.)

Similar Messages

  • Best way to do a tile-based map

    Hello everybody-
    This should be a simple thing but I just can't get it to work. I'm making a tile-based top-down online rpg (application, not applet), and I pretty much have most of it done except I can't get the map to display and scroll right. i will admit that java graphics isn't really my thing, but i just can't get it. Its been so frustrating that i actually quite develpment on my game and quit for awhile, but i decided to try again. What I have is an array if images that make up the map, and then i manipulate the array depending where the character is so i only draw the tiles necessary. what i want to do is to combine all the tiles i need for the particular position, draw that image to the screen (so i don't have to draw each tile individually to the screen). then i could move that large image depending where the character moved, and add tiles to it depending on which way the character moves. I just can't get it to work however. I've looked at double-bufferning posts and that gave me some ideas, but not enough for my particular situation. if anybody has any experience in this i would be more than greatful. thank you

    I know exactly what you are talking about, I had your problem a while back when I was doing mobile phone games.
    To reduce the number of cell draws needed, cells were only drawn when at the edges of the view area. (all other cells were maintained from the previously drawn frame.)
    It gets pretty complicated, but it will work - stick with it.
    I would post some code - but I don't have it anymore - and it was pretty specific to J2ME MIDP API (java mobile phone).
    p.s. When I did it, I had to include several additional optimisation, these made it incredibly complex :(
    I will try to describe it, but without pictures, It will probably be in vain. (don't worry if you don't understand it :P)
    here is the summary of the logic :-
    the backbuffer had dimensions SCREEN_WIDTH+CELL_WIDTH*2, SCREEN_HEIGHT+CELL_HEIGHT*2 (I effectively had a border that was CELL_WIDTH wide, and CELL_HEIGHT tall.)
    this meant new cells only had to be drawn every time the view area passed over a cell boundary.
    however, doing this, meant it was super smooth until it hit a cell boundary, at which point it had to draw all the cells in the newly exposed column and/or row - which caused a jerk.
    To get around this, I devised a speculative rendering, where by the next column/row was pre-rendered over a series of game frames.
    (each column/row had its own buffer into which the pre-rendering was done)
    On average 2-4 times as many edge cells had to be rendered than needed, but, because the camera moved slowly, this could be distributed over approx. 10 game frames.
    By distributing the rendering of the edge cells over a number of game frames, I hoped to remove the jerk experienced as the camera crossed a cell boundary.
    The system worked... ish... but I never finished it :(
    basically, these were crazy optimisations that were only necessary because I was developing for mobile phones.
    On mobile phones the speed of rendering is relative to the number of draw calls, NOT the actual area of the screen being repainted.
    e.g.
    fillRect(0,0,50,50)
    fillRect(0,50,50,50)
    will take almost twice as long as
    fillRect(0,0,100,100)
    even though you are only painting 1/2 the area.

  • Tile-based map and A-star help?

    I am working on a tower defense type game. A while ago I posted asking about maze logic and was kindly directed towards A-star pathfinding. It is perfect. I understand the concept and it makes sense. Now the problem I am having is how to do the tile-based map? I'm having a hard time wrapping my head around it. I just want to do a straight square map comprised of squares. I realize a 2D Array would probably be the best way just such as:
    int[][] map = new int[100][100]
    where there would be 100 x 100 tiles. I can then populate the array with numbers ie 0 = walkable, 1 = unwalkable. I can have my A* algorithm return the set of tiles to move to.
    My problem is that I don't want my game to be in pixels and I'm having a hard time understanding how to make the game appear tile based and large enough to be playable? ie. 1 tile = 30x30 pixels. If we are looking at it in terms of model and view, I understand the model part, but I am having a hard time translating to the view? How do I create a tile based view so that the user can only place towers on a tile(the mouse click location could be any point inside the tile)? Also, how would I keep the enemy units moving smoothly between tiles and not just jumping to the center of each tile?
    I got some great advice last time and any more advice or points in a good direction would be greatly appreciated.

    The reason to distribute your maze into nodes (tiles) is that pathfinding is slow, so you want to eliminate any notion of screen dimensions (pixels, inches, etc.) from A*. For all purposes, your maze is 100x100 pixels; any given object can choose between 100 horizontal and 100 vertical values.
    how would I keep the enemy units moving smoothly between tiles and not just jumping to the center of each tile?Although your units may only have 100x100 nodes to consider, you can still animate them walking between each adjacent node on the path. Remember that the pathfinding (per tier) will occur before anything actually moves.
    Still, this could look funny with only 100 nodes per axis. Units should use the shortest path that’s visible to them, and turning several degrees at each node will look choppy. So. I list three potential solutions here:
    • Increase the number of nodes (the “accuracy”). Speed may be an issue.
    • Use path smoothing algorithm. I haven’t seen your circumstance, but I would generally recommend this.
    • Use multi-tiered/hierarchical pathfinding. This is probably more complex to implement.
    Note that although the second and third options are distinct, they may coincide (some smoothing algorithms use multiple tiers). Googling for ‘pathfinding smoothing’ returned many results; this one in particular looked useful: [Toward More Realistic Pathfinding|http://www.gamasutra.com/features/20010314/pinter_01.htm]
    How do I create a tile based view so that the user can only place towers on a tile(the mouse click location could be any point inside the tile)?If objects can be placed at arbitrary points, then A* needs to deem nodes impassable (your array’s 1) based on the objects placed in them. You have to be careful here and decide whether entire nodes should be ignored based on tower’s partial presence; for instance:
    |====|====|====|====|====|
    |====|====|====|===+|+++=|
    |====|====|====|===+|+++=|
    |====|====|====|====|====|
    |0~0=|====|====|====|====|pixels: = ; node dividers: | (and line breaks for vertical) ; tower: +
    The tower only covers ¼ of the node at (3, 3); should you eliminate it? Five solutions are obvious:
    • Ignore any node with any chunk of a tower in it.
    • Ignore any node entirely covered by a tower.
    • Ignore any node whose center is covered by a tower. This won’t work with multi-tiered pathfinding.
    • Ignore any node that has a tower covering any point the units are required to pass through. This will work with multi-tiered pathfinding.
    • Using multi-tiered pathfinding, consider only consider the sub-nodes that aren’t covered by a tower.
    I realize a 2D Array would probably be the best way just such as
    int[][] map = new int[100][100]
    For starters, if only want two values—passable and impassible—then a boolean would be better. But I would recommend against this. I’d bet you could write some OO code specific to your situation. You might want to use terrain costs, where nodes exist that A* would prefer over others.
    I hope I answered some of your questions. Let me know if you have more—or if I didn’t.
    Good luck.
    —Douglas

  • How to animate from a png tile based image file

    Hi all,
    I would like to know is there any way to animate from a tile based .png image file? I have multiple images in 1 png file having slight changes in each image, which if cropped and put into layers one over the other, will give the feel of animation or a character moving or walking etc...
    I want to know can we do that kind of animation in flash as we do it in C++ or Java and how can we do it.
    Any help will be highly appreciated.
    Thank you
    Shanz - Iceheros

    I want to use action script to externally call/access  the png file with url request and url loader and animate the images from the tile based png image file.
    Anybody know how to do this in flash with as3.
    Here is the image for example:
    i want to animate this images and call it externally and access each tile 1 after another.
    Any Help???
    Thanks,
    Shanz - Iceheros

  • Effecient tile-based game setup

    Hello i am working on the engine for a tile based game, i have set up a two dimensional array with the number 1 representing a tile, and the number 0 representing an empty space. Currently i am using the following code which does work, but it is no very effecient because there are too many movieclips on the stage, which is causing my game to run at a lower framerate.
    function prepareGame():void
        for (var y:int = 0; y<mazeHeight; y++)
            for (var x:int = 0; x<mazeWidth; x++)
                if (myMaze[y][x] == 1)
                    var cell:MovieClip = new mc_tile();
                    cell.x = ts * x;
                    cell.y = ts * y;
                    addChild(cell);
    So my question is how do i optimize this code? If i could somehow make flash view all the movieclips as one big bitmap i guess that would solve the problem but i need some help.
    Any help is appreciated thank you!

    Here is an example of scrolling tiles (just paste the code on timeline).
    Background takes only stage dimensions but the impression is that it scrolls indefinitely.
    import flash.display.BitmapData;
    import flash.display.Graphics;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.geom.Point;
    import flash.geom.Rectangle;
    var board:Sprite;
    var bitmapData:BitmapData;
    var appendBitmapData:BitmapData;
    var copyRect:Rectangle;
    var zeroPoint:Point = new Point();
    var targetPoint:Point;
    var speed:Number = -1;
    init();
    function init():void
              drawBoard();
              setGeometry();
              addEventListener(Event.ENTER_FRAME, animate);
    function drawBoard():void
              board = new Sprite();
              var tileInstance:Sprite = tile;
              bitmapData = new BitmapData(tileInstance.width, tileInstance.height);
              bitmapData.draw(tileInstance);
              var g:Graphics = board.graphics;
              g.beginBitmapFill(bitmapData, null, true);
              g.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
              addChild(board);
    function setGeometry():void
              appendBitmapData = new BitmapData(Math.abs(speed), bitmapData.height, true, 0x00000000);
              copyRect = new Rectangle(0, 0, Math.abs(speed), bitmapData.height);
              targetPoint = new Point(bitmapData.width - 1, 0);
    function animate(e:Event):void
              bitmapData.lock();
              appendBitmapData.copyPixels(bitmapData, copyRect, zeroPoint);
              bitmapData.scroll(speed, 0);
              bitmapData.copyPixels(appendBitmapData, copyRect, targetPoint);
              bitmapData.unlock();
    function get tile():Sprite
              var s:Sprite = new Sprite();
              var g:Graphics = s.graphics;
              g.lineStyle(2, 0x004000);
              g.beginFill(0x009700);
              g.drawRect(1, 1, 80, 50);
              return s;

  • Tile Based Collision Detection

    I am following Tonypa's Tile Based Tutorials and I have to
    say, they are great. He covers everything needed, except for one
    thing I am troubled on - Refering to Tutorial 9,
    http://www.tonypa.pri.ee/tbw/tut09.html,
    Stupid Enemy, instead of an enemy I want to make this a NPC who
    walks around in a village. So what do I do to make it so that I, or
    the char, doesn't walk right over the enemy/NPC? I am trying to
    develop an RPG, and it would look silly to have the character walk
    on top of the NPC. Can someone provided a snippet on how to make a
    collision detection with the NPC and not walk on top/under the NPC?
    One last favor to ask: What if I want to talk to the NPC if I
    am within a half tile? Would anyone be willing to share info on how
    this as well?
    Thanks a bunch in advance

    Ok, let me see if I get the read correct here: you have your scenery objects as tiles and when moving your players/NPC's through the scenery you are not scrolling the background as you go, but when you get to s certain point you want to scroll the tiles of the background also, so you can have new scenery cycle in as needed an still have the tiled background objects and new tiled background objects work for collision detection.
    If my take on your project is correct, then you have to make your tiles addressed with relative addressing formulas as you'll probably need to do with your sprites also.
    So the way this will go is that you have to make an offset and add them into your formula based on your character position. Then based on your character position you can choose to scroll your tiles left, right, up, down or what ever you choose to support. As a tile falls fully off the screen, you can dispose of it or cycle back through depending on how you implement your background.

  • Smooth walking on tile based map system

    Hello,
    I am developing a small game which requires the use of a map system. I chose to make that map system work upon a tile-based system. At the moment, each tile is 32x32, and I contain 24x20 tiles on my map.
    A walking system is also required for this game I'm developing, so I ran into some issues with making the loaded sprite walk "smoothly". At the moment, it jumps from tile to tile in order to walk. This makes it seem very unrealistic. I have tried many different ways to make the walking "smoother", but it requires me to change my tile's size in order to accommodate the sprite's size. This would not be an issue if I only used the same sprite in the game, but since I load different sprites which contain different measurements, I do not know how to make my walking system accommodate all of the sprites in order to make the walking realistic.
    I am not requesting any code whatsoever, simply ideas.
    Thank you

    If your image is opaque, then it may draw the edges around itself, but wouldn't this be a problem wether it were completely contained within a tile or not? If the image has transparency, then it doesn't matter if it's drawn as a rectangle, it would still appear to be contained only by its outline.
    If you're using a back-buffer (which I highly recommend if there is going to be animation or movement onscreen), then you may need to specify the type for the BufferedImage that you use as a buffer, I always use TYPE_INT_ARGB to make sure I have Alpha values (transparency).

  • Tile Based Movement in AS3

    Hello i am still trying to create tile based movement. What i mean by that is the character can move smoothly but will always end up in the middle of a tile (just like the pokemon games). I have managed to make it work if the player uses only one key, however in combination with other keys it does not work. I was hoping someone could give me advise how to fix the code or perhaps some better/easier way to do it.
    Here is my code so far (this is only for left and right key) my character movieclip has the instance name char
    import flash.ui.Keyboard;
    import flash.events.KeyboardEvent;
    import flash.events.Event;
    import fl.transitions.easing.*;
    import com.greensock.*;
    var pixelsMoved:Number = 0;
    var pixelsLeft:Number = 0;
    var tweening:Boolean = false;
    var rightKeyDown:Boolean = false;
    var leftKeyDown:Boolean = false;
    addEventListener(Event.ENTER_FRAME,Loop);
    stage.addEventListener(KeyboardEvent.KEY_DOWN,KeyPress);
    stage.addEventListener(KeyboardEvent.KEY_UP,KeyRelease);
    function Loop(event:Event):void
        if (tweening == false)
            if (rightKeyDown == true)
                char.x += 1;
                pixelsMoved += 1;
            else if (leftKeyDown == true)
                char.x -= 1;
                pixelsMoved += 1;
            if (pixelsMoved >= 25)
                pixelsMoved = 0;
                pixelsLeft = 25;
    function KeyPress(event:KeyboardEvent):void
        if (event.keyCode == Keyboard.RIGHT)
            rightKeyDown = true;
        if (event.keyCode == Keyboard.LEFT)
            leftKeyDown = true;
    function KeyRelease(event:KeyboardEvent):void
        pixelsLeft = 25 - pixelsMoved;
        if (event.keyCode == Keyboard.RIGHT)
            if (tweening == false)
                var moveRight:TweenLite = new TweenLite(char,pixelsLeft,{x:char.x + pixelsLeft,ease:None.easeNone,useFrames: true,onComplete: resetVars});
            rightKeyDown = false;
            tweening = true;
        if (event.keyCode == Keyboard.LEFT)
            if (tweening == false)
                var moveLeft:TweenLite = new TweenLite(char,pixelsLeft,{x:char.x - pixelsLeft,ease:None.easeNone,useFrames: true,onComplete: resetVars});
            leftKeyDown = false;
            tweening = true;
    function resetVars():void
        tweening = false;
        pixelsLeft = 0;
        pixelsMoved = 0;
    Any help is much apreciated!

    I am not sure I understand all the requirements. Also I guess you refer to pacman game - not pokemon.
    In any case, here is something that works pretty smooth at 60fps. Note there are no ENTER_FRAME handlers - all animations are handled by TweenLite.
    Just dump the code on a timeline in a new FLA - it is not meant to be injected into your existing code. So, this is just an independent fully functional concept. All objects are created dynamically by the script - you don't have to do anything to view/test this example.
    Read comments.
    import com.greensock.easing.Ease;
    import com.greensock.easing.Linear;
    import com.greensock.easing.Sine;
    import com.greensock.TweenLite;
    import flash.display.Graphics;
    import flash.display.Shape;
    import flash.display.Sprite;
    import flash.events.KeyboardEvent;
    import flash.geom.Point;
    import flash.ui.Keyboard;
    var board:Sprite;
    var tileSide:Number = 40;
    var numRows:int = 10;
    var numCols:int = 14;
    var char:Shape;
    var _currentKey:uint = 0;
    var tween:TweenLite;
    init();
    function init():void
              drawBoard();
              configStage();
    function configStage():void
              stage.scaleMode = StageScaleMode.NO_SCALE;
              stage.align = StageAlign.TOP_LEFT;
              stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyPress);
              stage.addEventListener(KeyboardEvent.KEY_UP, onKeyRelease);
    function onKeyRelease(e:KeyboardEvent):void
              // if the latest processed key was not release - we block the latest pressed key
              if (e.keyCode == _currentKey)
                        _currentKey = 0;
    function onKeyPress(e:KeyboardEvent):void
              currentKey = e.keyCode;
    function get tile():Shape
              var shape:Shape = new Shape();
              shape.cacheAsBitmap = true;
              var color:uint = 0x808080;
              var g:Graphics = shape.graphics;
              g.lineStyle(1, color);
              g.beginFill(0xEBEBEB);
              g.drawRect(-tileSide / 2, -tileSide / 2, tileSide, tileSide);
              return shape;
    function moveChar(targetX:int = 0, targetY:int = 0):void
              tween = TweenLite.to(char, 0.45, {x: targetX, y: targetY, ease: Linear.easeNone, onComplete: onTweenComplete});
    function onTweenComplete():void
               * need to do that
               * a. if key is kept pressed
               * c. to override situations when another key is pressed simulataneously
              currentKey = _currentKey;
    function set currentKey(value:uint):void
              var targetPosition:Number = 0;
               * key value is proccessed if
               * a. key is allowed - via switch
               * b. there is no key pressed before or ptreviously pressed key _currentKey is the same as new value
               * c. tween in not active
              if ((!_currentKey || _currentKey == value) && !tween._active)
                        switch (value)
                                  case Keyboard.RIGHT:
                                            targetPosition = char.x + tileSide;
                                            if (targetPosition < tileSide * numCols)
                                                      moveChar(targetPosition, char.y);
                                                      charRotation = 0;
                                            _currentKey = value;
                                            break;
                                  case Keyboard.LEFT:
                                            targetPosition = char.x - tileSide;
                                            if (targetPosition >= 0)
                                                      moveChar(targetPosition, char.y);
                                                      charRotation = 180;
                                            _currentKey = value;
                                            break;
                                  case Keyboard.UP:
                                            targetPosition = char.y - tileSide;
                                            if (targetPosition >= 0)
                                                      moveChar(char.x, targetPosition);
                                                      charRotation = -90;
                                            _currentKey = value;
                                            break;
                                  case Keyboard.DOWN:
                                            targetPosition = char.y + tileSide;
                                            if (targetPosition < tileSide * numRows)
                                                      moveChar(char.x, targetPosition);
                                                      charRotation = 90;
                                            _currentKey = value;
                                            break;
    function set charRotation(value:Number):void
              if (char.rotation == -180)
                        char.rotation = 180;
              if (char.rotation == 180 && value == -90)
                        char.rotation = -180;
              else if (char.rotation == -90 && value == 180)
                        value = -180;
              TweenLite.to(char, 0.2 * (Math.abs((char.rotation - value) / 90) || 1), {rotation: value});
    function drawBoard():void
              board = new Sprite();
              var numTiles:int = numRows * numCols;
              for (var i:int = 0; i < numTiles; i++)
                        var t:Shape = tile;
                        t.x = tileSide * (i % numCols);
                        t.y = tileSide * int(i / numCols);
                        board.addChild(t);
              board.addChild(addChar);
              addChild(board);
              board.x = board.y = 20 + tileSide / 2;
    function get addChar():Shape
              var radius:Number = tileSide / 2 - 4;
              char = new Shape();
              var g:Graphics = char.graphics;
              g.lineStyle(1);
              g.beginFill(0xff0000);
              g.drawCircle(0, 0, radius);
              g.endFill();
              g.lineStyle(2);
              g.moveTo(0, 0);
              g.lineTo(radius, 0);
              g.beginFill(0x000000);
              g.moveTo(radius, 0);
              g.lineTo(radius - 10, 4);
              g.lineTo(radius - 10, -4);
              g.endFill();
              tween = new TweenLite(char, 1, null);
              char.cacheAsBitmap = true;
              return char;

  • Layers problem in PS cs5 extended, all layers change at once, including background layer.

    layers problem in PS cs5 extended, when working in a layer, all layers changes at once i.e size, cropping, smart object etc. even the background layer changes...it is really annoying, please help, My system windows 7 64 bit  4gb ram.  It is not grouped, deleted preferences, usually work in rgb/ 8 bit channel - have same problem with all new projects.

    Hi
    Problem with layers is when I use the crop tool in a layer out of 20, all of them get croped at once including a locked backgound layer.
    When I use smart object in a layer to size down image with transform tool, guess what happens to all the layers in project? all behave odd, changes same as the layer being sized down. If I work images or layers in separate files, once I bring them over to my workspace, all get affected without maintaining their own individuality. This happens with every new project. I think colors are not affecting layers. Layers are not grouped, I do not know anything about linking layers. This problem is stopping me from using photoshop. Please help!!!   
    I had previously a problem with a photoshop bug (GPU sniffer), which I was able to resolve it with reintalling the graphics video card with the help of HP technical support, I am able now to work with repousse however with same video card.
    Let me know if you need me to give you more details.
    thanks,

  • Tile based pathfinding

    Allright i am about to start working on something that i have never tried before. I am making a tile based game which is set up with a two-dimensional array.
    0 in the array represents wall tiles which aren't walkable.
    1 in the array represents path tiles which can be walked on.
    I would like to add some enemies to the game which i want to have following the character. The enemies must follow the character by walking on the shortest route possibly. I have tried looking into path-finding but it seems quite complex. If anyone has some advice on how i would go about doing this, i would very much love to hear. Maybe if someone can recommend a good tutorial that would be nice.
    Thanks in advance!

    Here's your typical A* pathfinding explained:
    http://www.raywenderlich.com/4946/introduction-to-a-pathfinding

  • RPG Tile Based Map Programming

    Does anybody have any experience in this area? I have an online rpg type game that I'm working on and its going fine, the only problem is that the map scrolls too slow so your character moves too slowly. For my map I simply extended a JPanel. For every tile the character moves(one tile = 32 pixels) the screen is redrawn 8 times (each redraw basically moves the whole screen 4 pixels in the desired direction) in this way the screen moves very smoothly and character animation is smooth, but it is also pretty slow. Can anybody offer any suggestions? I would love to talk with people who have done this type of thing before becuase it is my first stab at it. thanks.

    the reason your drawing is slow, is because you are redrawing every cell, every frame. This is unnecessary, as you can reuse the cells you drew in the previous frame, by simply shifting them by the appropriate amount.
    let me clarify:
    I will use some real numbers to demonstrate the optimisation.
    screenWidth=800, screenHeight=640, cellWidth=32, cellHeight=32;
    scrollSpeed=8; // << the number of frames it takes to move by 1 complete cell
    just to render the background, your current approach calls drawImage this many times every frame
    (screenWidth/cellWidth+1)*(screenHeight/cellHeight+1)
    e.g. (800/32 +1)*(640/32+1) = 546 cell redraws/frame
    There are several approaches you can use to fix this, all require the use of a cellBuffer to cache the previously drawn cells.
    1) draw the cellBuffer onto itself, and redraw all the cells that have become corrupt.
    Approach will require (screenWidth/cellWidth+1)+(screenHeight/cellHeight+1) cell redraws
    e.g. 800/32+1 +640/32+1 = 47 cell redraws/frame
    2) have an oversized cellBuffer (with dimensions of screenWidth+cellWidth*2 by screenHeight+cellHeight*2).
    With this method, redraw of exposed cells is only necessary every time you cross a cell boundary, not every frame rendered.
    Assuming you are moving at a constant 4 pixels/frame as you describe in your question, that will mean
    e.g. 800/32+1 +640/32+1 = 47 cell redraws every 8th frame (an average of 5.9 celldraws/frame)
    This method has the lowest number of celldraws per frame. However, because you draw all newly exposed cells, in 1 go, you end up with choppy scrolling.
    3) This method attempts to solve the problem of choppy scrolling, by using predictive edge cell drawing, and distributing the cell rendering over multiple frames. (giving a more consistant frame rate)
    using this method, requires you to have 4 additional buffers (1 for each edge of the screen)
    into these buffers, the predicted cells will be cached.
    This algorithm has 2 important factors deciding its efficiency, if the viewport scrolls quickly, its efficiency will drop massively.
    The accuracy to which you can predict which edge buffer to fill up first also greatly influences the algorithms efficiency - therefor it is better suited to use in an environment where the direction of scrolling doesn't change rapidly.
    Best case performance is ((screenWidth/cellWidth+1)+(screenHeight/cellHeight+1))/scrollSpeed (assumes you are moving in both axis, if only moving in 1 axis, the performance would be even better)
    e.g. ((800/32+1)+ (640/32+1))/8= 5.9 cells/frame
    Worst case performance is ((screenWidth/cellWidth+1)*2 + (screenHeight/cellHeight+1)*2) /scrollSpeed
    e.g. ((800/32+1)*2 + (640/32+1)*2)/8 = 52+42/8 = 11.8 cells/frame.
    So, as long as you scroll at a constant 1 cell every 8 frames, this algorithm will give you a performance per frame of between
    5.9 and 11.8 cells/frame.
    As you can see, even the simple method highlighted in method 1) is approx. 9 times faster than your current method.
    and, if the choppy scrolling of method 2), or the limitations imposed by method 3) are acceptable for your implementation, you can get an algorithm that will run approx. 50-100 times faster than your current method.

  • Loading and Saving problem in 2D space based rpg

    I am implementing a system in which the game saves the offset of the default position of an object in space and the object's position when the game is saved and applying that to the objects when the game is loaded. I get a strange problem however where every other undock after loading the game is far far away in space. I think it has something to do with the saved position of the object you docked with. Here is the code involved in loading the game (it just calls IO.java via dataAgent and gets data from a file)
    public void loadGame() throws FileNotFoundException, IOException {
            //load the game
            String[] tmpData = null;
            tmpData = dataAgent.loadGame();
            //interpet the data
            hud.currentDockedCelestialObject = Integer.parseInt(tmpData[0]) - 1;
            player.currentWallet = Integer.parseInt(tmpData[1]) - 1;
            player.currentSolarSystem = space[hud.currentDockedCelestialObject].solar;
            hud.renderMode = 1;
            hud.player = player;
            hud.space = space;
            hud.dPressed = true; //tell HUD we are docked at something
            //now we need to determine the position of all the celestial objects based on the saved position of the object in question
            int tmpx = Integer.parseInt(tmpData[2]) - 1;
            int tmpy = Integer.parseInt(tmpData[3]) - 1;
            //compare it to the docked celestial
            int changex = space[hud.currentDockedCelestialObject].positionX - tmpx;
            int changey = space[hud.currentDockedCelestialObject].positionY - tmpy;
            //apply the offset to all the objects in the current solar system
            for (int i = 0; i < space.length; i++) {
                if (space.solar.matches(player.currentSolarSystem)) {
    space[i].positionX += changex;
    space[i].positionY += changey;
    //now we need to load the ship type
    player.ship.type = Integer.parseInt(tmpData[4]);
    //configure the shields and hulls
    configureLoadedShip();
    //finish up
    hud.space = space;
    hud.player = player;
    Configureloadedship() just makes a call to apply the correct weapons and armor to the ship you have. Here is the saving code:public void saveGame() {
    //saves the game
    String[] toSave = new String[5];
    toSave[0] = "" + (hud.currentDockedCelestialObject + 1);
    toSave[1] = "" + (hud.player.currentWallet + 1);
    toSave[2] = "" + (space[hud.currentDockedCelestialObject].positionX);
    toSave[3] = "" + (space[hud.currentDockedCelestialObject].positionY);
    toSave[4] = "" + (hud.player.ship.type);
    try {
    dataAgent.saveGame(toSave);
    } catch (IOException ex) {
    Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    Adding and subtracting 1 durring load and save solved the problem of the java file reader skipping the 0 values in the first few lines of the saved game file.
    The game is loaded when the game starts and saved when you dock.
    Ty in advance for your help.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    public String[] loadGame() throws FileNotFoundException, IOException /*should never be thrown*/ {
            String[] toReturn = null;
            //load the data
            FileReader read = new FileReader(data);
            BufferedReader buff = new BufferedReader(read);
            String tmp1 = "";
            String tmp2 = "";
            while((tmp1 = buff.readLine())!=null) {
                tmp2 = tmp2 + tmp1+"~";
            //break it into a usable form
            toReturn = tmp2.split("~");
            System.out.println(tmp2);
            return toReturn;
        }and
    public void saveGame(String[] toSave) throws IOException {
            FileWriter write = new FileWriter(data);
            BufferedWriter buff = new BufferedWriter(write);
            //clear the old file
            data.delete();
            data.createNewFile();
            //zap the data to the file
            for(int i = 0; i < toSave.length; i++) {
                buff.write(toSave);
    buff.newLine();
    //write
    buff.flush();
    }They are basically just buffered readers and writers.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • View with columns based on function - problem with query

    Hi,
    I'm using Oracle 9i;
    I've created a view which has columns based on a table columns (multiple columns from 1 table) and funtion (multiple columns based on 1 function).
    The function takes ID as the first argument and name of the column to determine which value to return as the second one.
    Here is a sample of such function (simplified):
    FUNCTION my_function
    (in_id IN NUMBER, in_col_name IN VARCHAR2)
    RETURN VARCHAR2
    IS
    c_name VARCHAR2(100);
    c_last_name VARCHAR2(100);
    BEGIN
    SELECT T.NAME, T.LAST_NAME
    INTO c_name, c_last_name
    FROM TABLE_1 T, TABLE_2 Z
    WHERE T.PK = Z.FK
    AND Z.ID = in_id;
    IF in_col_name = 'NAME' THEN
    RETURN c_name;
    ELSIF in_col_name = 'LAST_NAME' THEN
    RETURN c_last_name;
    END IF;
    END;
    For simplicty I've restricted the number of columns.
    CREATE OR REPLACE VIEW my_view
    (ID, NAME, LAST_NAME)
    AS
    SELECT
    T.ID ID
    ,CAST(my_function(T.ID,'NAME') AS VARCHAR2(100)) NAME
    ,CAST(my_function(T.ID,'LAST_NAME') AS VARCHAR2(100)) LAST_NAME
    FROM TABLE T;
    There is no problem with query:
    SELECT * FROM my_view;
    The problem arises when I query the view (regardles of '=' or 'LIKE'):
    SELECT * FROM my_view
    WHERE name LIKE '%some_part_of_name%'
    The query returns rows for same names, for same it doesn't. If I put '=' and the whole name the query returns nothing, but when I put 'LIKE' and the first letter it returns rows in some cases.
    I've tried to debug this situation and I've discovered that the function recives ID not in the proper order and not the same amount of times - in explicit:
    for each ID in (1, 2, 3, 4, 5, 6, ... , 100) the function should be called twice for each ID and in the same order, but it does not.
    I get 1, 1, 2, 3, 3, 6, 20, 20 and so on.
    Help needed.
    Greetings.

    The problem is more complicated than the solutions provided here.
    The reason why I'm using the function is this:
    the original view was constructed using multiple union all selects and the speed was terrible. I've created the index on the base table to obtain a proper sort. For retriving all records at once the view works perfectly, but if one wants to query by columns based on function the results are suprisng - sometimes there are, some times there are none, or if you serch with "like" and only a part of string there are results, but with "=" there are no results.
    Here are real DDLs:
    View:
    CREATE OR REPLACE VIEW V_DOK_ARCH
    (ID_ZDAR, TYP, STAN, DATE_CREATED, CREATED_BY,
    DATE_MODIFIED, MODIFIED_BY, SPRA_ID_SPRA, PODM_ID_PODM, PODM_UMOW_ID_UMOW,
    NR_WFS, WFS_NR_INTER, UWAGI_OPER, FUNDUSZ, NUMER,
    DATA_PODPISANIA, RODZAJ, TYP_PRZY, TYP_UBEZ, NAZWISKO,
    IMIE, IMIE_OJCA, NAZWA_FIRMY, NAZWA_FIRMY_SKR, DANE_KLIE)
    AS
    SELECT /*+ INDEX(Z ZDAR_DATE_CREATED_DESC_I) */
    Z.ID_ZDAR ID_ZDAR
    , Z.TYP TYP
    , Z.STAN STAN
    , Z.DATE_CREATED DATE_CREATED
    , Z.CREATED_BY CREATED_BY
    , Z.DATE_MODIFIED DATE_MODIFIED
    , Z.MODIFIED_BY MODIFIED_BY
    , Z.SPRA_ID_SPRA SPRA_ID_SPRA
    , Z.PODM_ID_PODM PODM_ID_PODM
    , Z.PODM_UMOW_ID_UMOW PODM_UMOW_ID_UMOW
    , Z.NR_WFS NR_WFS
    , Z.WFS_NR_INTER WFS_NR_INTER
    , Z.UWAGI_OPER UWAGI_OPER
    , Z.FUNDUSZ FUNDUSZ
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NUMER') AS VARCHAR2(30)) NUMER
    , F_Rej_Zdar_Date(Z.ID_ZDAR, 'DATA_PODPISANIA') DATA_PODPISANIA
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'RODZAJ') AS VARCHAR2(4)) RODZAJ
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'TYP_PRZY') AS VARCHAR2(4)) TYP_PRZY
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'TYP_UBEZ') AS VARCHAR2(3)) TYP_UBEZ
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWISKO') AS VARCHAR2(30)) NAZWISKO
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE') AS VARCHAR2(30)) IMIE
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE_OJCA') AS VARCHAR2(30)) IMIE_OJCA
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY') AS VARCHAR2(300)) NAZWA_FIRMY
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY_SKR') AS VARCHAR2(100)) NAZWA_FIRMY_SKR
    , CAST(LTRIM(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWISKO')||' '||F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE')||' '||F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE_OJCA')||F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY')||DECODE(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY'),NULL,F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY_SKR'),NULL)) AS VARCHAR2(492)) DANE_KLIE
    FROM T_ZDARZENIA Z
    WHERE F_Rej_Zdar_Char(Z.ID_ZDAR, 'JEST') = 'T';
    and functions:
    CREATE OR REPLACE FUNCTION F_Rej_Zdar_Char
    (WE_ID_ZDAR IN NUMBER
    ,WE_KOLUMNA IN VARCHAR2
    RETURN VARCHAR2
    IS
    c_numer           T_PRZYSTAPIENIA.NUMER%TYPE;--VARCHAR2(30);
    c_rodzaj           T_KLIENCI.RODZAJ%TYPE;--VARCHAR2(1);
    c_typ_przy           T_PRZYSTAPIENIA.TYP_PRZY%TYPE;--VARCHAR2(1);
    c_typ_ubez           T_PRZYSTAPIENIA.TYP_UBEZ%TYPE;--VARCHAR2(3);
    c_nazwisko           T_KLIENCI.NAZWISKO%TYPE;--VARCHAR2(30);
    c_imie                T_KLIENCI.IMIE%TYPE;--VARCHAR2(30);
    c_imie_ojca      T_KLIENCI.IMIE_OJCA%TYPE;--VARCHAR2(30);
    c_nazwa_firmy      T_KLIENCI.NAZWA_FIRMY%TYPE;--VARCHAR2(300);
    c_nazwa_firmy_skr T_KLIENCI.NAZWA_FIRMY%TYPE;--VARCHAR2(100);
    c_jest                VARCHAR2(1) := 'T';
    c EXCEPTION;
    BEGIN
    --dbms_output.put_line('id zdar wykonania '||WE_ID_ZDAR);
    BEGIN
    SELECT p.NUMER, k.RODZAJ,p.TYP_PRZY,p.TYP_UBEZ,k.nazwisko, k.imie, k.imie_ojca, k.nazwa_firmy, k.nazwa_firmy_skr
    INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
    FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D1, T_PODMIOTY D2
    WHERE p.KLIE_ID_KLIE = k.ID_KLIE
    AND z.PODM_ID_PODM = D1.ID_PODM
    AND D1.KLIE_ID_KLIE = p.KLIE_ID_KLIE
    AND Z.PODM_UMOW_ID_UMOW = D2.ID_PODM
    AND D2.PRZY_ID_PRZY = P.ID_PRZY
    AND z.ID_ZDAR = WE_ID_ZDAR;
    EXCEPTION
         WHEN NO_DATA_FOUND THEN
         BEGIN
         SELECT p.NUMER, k.RODZAJ,p.TYP_PRZY,p.TYP_UBEZ,k.nazwisko, k.imie, k.imie_ojca, k.nazwa_firmy, k.nazwa_firmy_skr
         INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
         FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D
         WHERE z.PODM_UMOW_ID_UMOW IS NULL
         AND z.PODM_ID_PODM = D.ID_PODM
         AND D.KLIE_ID_KLIE = k.ID_KLIE
         AND p.KLIE_ID_KLIE = k.ID_KLIE
         AND z.ID_ZDAR = WE_ID_ZDAR;
         EXCEPTION
              WHEN NO_DATA_FOUND THEN
              BEGIN
              SELECT NULL NUMER, NULL RODZAJ,NULL TYP_PRZY,NULL TYP_UBEZ, I.nazwisko, I.imie, I.imie_ojca, I.NAZWA NAZWA_FIRMY, I.NAZWA_SKR nazwa_firmy_skr
              INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
              FROM T_ZDARZENIA z, T_INSTYTUCJE I
              WHERE Z.TYP IN ('WFS526','WFS542','WFS553','WFS609','WFS611','WYP_KS','WYP_PO','WYP_SB','DI_ZAT')
              AND z.PODM_UMOW_ID_UMOW IS NULL
              AND Z.PODM_ID_PODM = I.ID_INST
              AND z.ID_ZDAR = WE_ID_ZDAR;
              EXCEPTION
                   WHEN NO_DATA_FOUND THEN
                   BEGIN
                   SELECT p.NUMER NUMER, DECODE(a.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(a.TYP_AGENTA,'P','R',a.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,a.nazwisko, a.imie, a.imie_ojca, a.nazwa_firmy, a.nazwa_firmy_skr
                   INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                   FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
                   WHERE a.ID_AGAG = p.AGAG_ID_AGAG
                   AND z.PODM_UMOW_ID_UMOW = p.ID_AGUM
                   AND z.ID_ZDAR = WE_ID_ZDAR;
                   EXCEPTION
                        WHEN NO_DATA_FOUND THEN
                        BEGIN
                        SELECT p.NUMER NUMER, DECODE(a.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(a.TYP_AGENTA,'P','R',a.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,a.nazwisko, a.imie, a.imie_ojca, a.nazwa_firmy, a.nazwa_firmy_skr
                        INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                        FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
                        WHERE a.ID_AGAG = p.AGAG_ID_AGAG
                        AND z.PODM_ID_PODM = a.ID_AGAG
                        AND z.PODM_UMOW_ID_UMOW IS NULL
                        AND z.ID_ZDAR = WE_ID_ZDAR;
                        EXCEPTION
                             WHEN NO_DATA_FOUND THEN
                             BEGIN
                             SELECT p.NUMER_UMOWY NUMER, DECODE(p.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(p.TYP_AGENTA,'P','R',p.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,p.nazwisko, p.imie_pierwsze, p.imie_ojca, p.nazwa_firmy, p.nazwa_firmy_skr
                             INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                             FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
                             WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
                             AND z.PODM_UMOW_ID_UMOW = p.TECH_ID_AGUMT
                             AND z.ID_ZDAR = WE_ID_ZDAR;
                             EXCEPTION
                                  WHEN NO_DATA_FOUND THEN
                                  BEGIN
                                  SELECT p.NUMER_UMOWY NUMER, DECODE(p.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(p.TYP_AGENTA,'P','R',p.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,p.nazwisko, p.imie_pierwsze, p.imie_ojca, p.nazwa_firmy, p.nazwa_firmy_skr
                                  INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                                  FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
                                  WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
                                  AND z.PODM_ID_PODM = a.ID_AGKAN
                                  AND z.PODM_UMOW_ID_UMOW IS NULL
                                  AND z.ID_ZDAR = WE_ID_ZDAR;
                                  EXCEPTION
                                       WHEN NO_DATA_FOUND THEN
                                       BEGIN
                                       SELECT k.NUMER_UMOWY NUMER, DECODE(k.TYP_PRZYSTAPIENIA,'P','F','P') RODZAJ,k.TYP_PRZYSTAPIENIA TYP_PRZY,'NPO' TYP_UBEZ, k.nazwisko, k.imie_pierwsze, k.imie_ojca, k.nazwa_firmy nazwa_firmy, k.nazwa_firmy_skr nazwa_firmy_skr
                                       INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                                       FROM T_WE_UM_NPO_TAB k, T_ZDARZENIA z
                                       WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
                                       AND k.TYP_PRZYSTAPIENIA IN ('P','W')
                                       AND z.PODM_ID_PODM IS NULL
                                       AND z.PODM_UMOW_ID_UMOW IS NULL
                                       AND z.ID_ZDAR = WE_ID_ZDAR;
                                       EXCEPTION
                                            WHEN NO_DATA_FOUND THEN
                                            BEGIN
                                            SELECT k.NUMER_UMOWY NUMER, 'F' RODZAJ,'-' TYP_PRZY,'OPS' TYP_UBEZ, k.nazwisko, k.imie_pierwsze, k.imie_ojca, NULL nazwa_firmy, NULL nazwa_firmy_skr
                                            INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                                            FROM T_WE_UM_OPS_TAB k,T_ZDARZENIA z
                                            WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
                                            AND z.PODM_ID_PODM IS NULL
                                            AND z.PODM_UMOW_ID_UMOW IS NULL
                                            AND z.ID_ZDAR = WE_ID_ZDAR;
                                            EXCEPTION
                                                 WHEN NO_DATA_FOUND THEN
                                                 BEGIN
                                                 SELECT NULL NUMER, NULL RODZAJ,NULL TYP_PRZY,NULL TYP_UBEZ, NULL nazwisko, NULL imie_pierwsze, NULL imie_ojca, NULL nazwa_firmy, NULL nazwa_firmy_skr
                                                 INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                                                 FROM T_ZDARZENIA z
                                                 WHERE z.TYP NOT IN ('UM_OPS','UM_NPO','NPO_OP','UZUP_U')
                                                 AND z.PODM_ID_PODM IS NULL
                                                 AND z.PODM_UMOW_ID_UMOW IS NULL
                                                 AND z.ID_ZDAR = WE_ID_ZDAR;
                                                 EXCEPTION
                                                      WHEN NO_DATA_FOUND THEN
                                                           --dbms_output.put_line('id zdar wykonania '||WE_ID_ZDAR||' ostatni wyjatek');
                                                           NULL;
                                                 END;
                                            END;
                                       END;
                                  END;
                             END;
                        END;
                   END;
              END;
         END;
    END;
    --raise c;
    IF WE_KOLUMNA = 'NUMER' THEN
    RETURN c_numer;
    ELSIF WE_KOLUMNA = 'RODZAJ' THEN
    RETURN c_rodzaj;
    ELSIF WE_KOLUMNA = 'TYP_PRZY' THEN
    RETURN c_typ_przy;
    ELSIF WE_KOLUMNA = 'TYP_UBEZ' THEN
    RETURN c_typ_ubez;
    ELSIF WE_KOLUMNA = 'NAZWISKO' THEN
    RETURN c_nazwisko;
    ELSIF WE_KOLUMNA = 'IMIE' THEN
    RETURN c_imie;
    ELSIF WE_KOLUMNA = 'IMIE_OJCA' THEN
    RETURN c_imie_ojca;
    ELSIF WE_KOLUMNA = 'NAZWA_FIRMY' THEN
    RETURN c_nazwa_firmy;
    ELSIF WE_KOLUMNA = 'NAZWA_FIRMY_SKR' THEN
    RETURN c_nazwa_firmy_skr;
    ELSIF WE_KOLUMNA = 'JEST' THEN
    RETURN c_jest;
    END IF;
    END;
    CREATE OR REPLACE FUNCTION F_Rej_Zdar_Date
    (WE_ID_ZDAR IN NUMBER
    ,WE_KOLUMNA IN VARCHAR2
    RETURN DATE
    IS
    d_data DATE;
    BEGIN
    BEGIN
    SELECT p.DATA_PODPISANIA
    INTO d_data
    FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D1, T_PODMIOTY D2
    WHERE p.KLIE_ID_KLIE = k.ID_KLIE
    AND z.PODM_ID_PODM = D1.ID_PODM
    AND D1.KLIE_ID_KLIE = p.KLIE_ID_KLIE
    AND Z.PODM_UMOW_ID_UMOW = D2.ID_PODM
    AND D2.PRZY_ID_PRZY = P.ID_PRZY
    AND z.ID_ZDAR = WE_ID_ZDAR;
    EXCEPTION
         WHEN NO_DATA_FOUND THEN
         BEGIN
         SELECT p.DATA_PODPISANIA
         INTO d_data
         FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D
         WHERE z.PODM_UMOW_ID_UMOW IS NULL
         AND z.PODM_ID_PODM = D.ID_PODM
         AND D.KLIE_ID_KLIE = k.ID_KLIE
         AND p.KLIE_ID_KLIE = k.ID_KLIE
         AND z.ID_ZDAR = WE_ID_ZDAR;
         EXCEPTION
              WHEN NO_DATA_FOUND THEN
              BEGIN
              SELECT NULL DATA_PODPISANIA
              INTO d_data
              FROM T_ZDARZENIA z, T_INSTYTUCJE I
              WHERE Z.TYP IN ('WFS526','WFS542','WFS553','WFS609','WFS611','WYP_KS','WYP_PO','WYP_SB','DI_ZAT')
              AND z.PODM_UMOW_ID_UMOW IS NULL
              AND Z.PODM_ID_PODM = I.ID_INST
              AND z.ID_ZDAR = WE_ID_ZDAR;
              EXCEPTION
                   WHEN NO_DATA_FOUND THEN
                   BEGIN
                   SELECT p.DATA_PODPISANIA DATA_PODPISANIA
                   INTO d_data
                   FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
                   WHERE a.ID_AGAG = p.AGAG_ID_AGAG
                   AND z.PODM_UMOW_ID_UMOW = p.ID_AGUM
                   AND z.ID_ZDAR = WE_ID_ZDAR;
                   EXCEPTION
                        WHEN NO_DATA_FOUND THEN
                        BEGIN
                        SELECT p.DATA_PODPISANIA DATA_PODPISANIA
                        INTO d_data
                        FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
                        WHERE a.ID_AGAG = p.AGAG_ID_AGAG
                        AND z.PODM_ID_PODM = a.ID_AGAG
                        AND z.PODM_UMOW_ID_UMOW IS NULL
                        AND z.ID_ZDAR = WE_ID_ZDAR;
                        EXCEPTION
                             WHEN NO_DATA_FOUND THEN
                             BEGIN
                             SELECT p.DATA_PODPISU_AGENTA DATA_PODPISANIA
                             INTO d_data
                             FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
                             WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
                             AND z.PODM_UMOW_ID_UMOW = p.TECH_ID_AGUMT
                             AND z.ID_ZDAR = WE_ID_ZDAR;
                             EXCEPTION
                                  WHEN NO_DATA_FOUND THEN
                                  BEGIN
                                  SELECT p.DATA_PODPISU_AGENTA DATA_PODPISANIA
                                  INTO d_data
                                  FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
                                  WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
                                  AND z.PODM_ID_PODM = a.ID_AGKAN
                                  AND z.PODM_UMOW_ID_UMOW IS NULL
                                  AND z.ID_ZDAR = WE_ID_ZDAR;
                                  EXCEPTION
                                       WHEN NO_DATA_FOUND THEN
                                       BEGIN
                                       SELECT k.DATA_PODPISANIA_UM DATA_PODPISANIA
                                       INTO d_data
                                       FROM T_WE_UM_NPO_TAB k, T_ZDARZENIA z
                                       WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
                                       AND k.TYP_PRZYSTAPIENIA IN ('P','W')
                                       AND z.PODM_ID_PODM IS NULL
                                       AND z.PODM_UMOW_ID_UMOW IS NULL
                                       AND z.ID_ZDAR = WE_ID_ZDAR;
                                       EXCEPTION
                                            WHEN NO_DATA_FOUND THEN
                                            BEGIN
                                            SELECT k.DATA_PODPISANIA_UM DATA_PODPISANIA
                                            INTO d_data
                                            FROM T_WE_UM_OPS_TAB k,T_ZDARZENIA z
                                            WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
                                            AND z.PODM_ID_PODM IS NULL
                                            AND z.PODM_UMOW_ID_UMOW IS NULL
                                            AND z.ID_ZDAR = WE_ID_ZDAR;
                                            EXCEPTION
                                                 WHEN NO_DATA_FOUND THEN
                                                 BEGIN
                                                 SELECT NULL DATA_PODPISANIA
                                                 INTO d_data
                                                 FROM T_ZDARZENIA z
                                                 WHERE z.TYP NOT IN ('UM_OPS','UM_NPO','NPO_OP','UZUP_U')
                                                 AND z.PODM_ID_PODM IS NULL
                                                 AND z.PODM_UMOW_ID_UMOW IS NULL
                                                 AND z.ID_ZDAR = WE_ID_ZDAR;
                                                 EXCEPTION
                                                      WHEN NO_DATA_FOUND THEN
                                                           d_data := NULL;
                                                 END;
                                            END;
                                       END;
                                  END;
                             END;
                        END;
                   END;
              END;
         END;
    END;
    IF WE_KOLUMNA = 'DATA_PODPISANIA' THEN
    RETURN d_data;
    END IF;
    END;

  • 2 player web-based Flash game problem

    I have a two player web-based Flash game. The Flash calls a
    JavaScript function on the webpage to get and store the user's IP.
    Then an XML file with user's game data is loaded and parsed. The IP
    address is used to identify which player is player 1 and which is
    player 2 according to the XML file. There is a Java applet to send
    and receive messages between the players.
    The first player loads everything just fine. All the first
    player's messages regarding the progress in loading different parts
    of the code sent by the game for debugging are displayed in the
    Java applet's text box, but none of the second player's messages
    sent by the game for debugging are displayed.
    The problem is that the second player's ActionScript code
    appears not to be executing except that I do get a message in the
    game that the XML file attempted to load but was not successful.
    The IP address call is not made and no messages can be sent to the
    other player. The second player's Java applet displays only the
    messages for debugging that came from the first player's game and
    any chat messages sent by the first player.
    This problem always happens to the second player, never to
    the first player. Both player's are always using IE6 or IE7.
    Does anyone have some idea(s) what could cause only the
    second player's ActionScript code not to execute and/or not to load
    an XML file correctly?
    This is just a general question, so any general answers would
    be appreciated. Code specific answers are hopefully not required.
    Thank You in advance.

    Hi,
    I am not very familiar with the multiplayer Game development. For multiplayer games, you'll need to set up a matchmaking server and have the clients connect to it. It can then pair them off and facilitate communications. If the clients have publicly available
    network addresses then it can introduce them and they can talk directly to each other.There isn't anything built in for this so you'll need to either build your own or find a third party implementation. If you are using Unity3d then check out
    http://docs.unity3d.com/Documentation/Components/net-MasterServer.html
    Also, you can use Xbox services, and I find an article below:
    https://msdn.microsoft.com/en-us/library/bb975801.aspx
    For windows Azure problem, you should go to windows Azure forum.
    Best Wishes!
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a
    href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

  • Hide/Show a button on a tile, based on the tileset you're in.

    Hey,
    I made a new tileset Z_CustomerPlan, it has an existing tile in it, capshort1.
    I added a button to this existing tile capshort1, named Z_BTNPreviewAll.
    But this button should ONLY be visible when in the new tileset Z_CustomerPlan because capshort1 is used in some other tilesets.
    i tried to do this with the following code in the onload event of capshort1:
    if not mcore.uftileset = "SZ_CustomerPlan" then
         ctrlZ_BTNPreviewAll.visible = false
    end if
    but this isnt working, it makes the button invisible on all tilesets, including Z_CustomerPlan.
    So im trying to show/hide the button based on the tileset... is this the right way?
    Some help would be nice.
    Cheers,
    Maarten

    Hey Vadim,
    After an intensive investigation i came to the following conclusion...
    if not mcore.uftileset = "SZ_CustomerPlan" then
         ctrlZ_BTNPreviewAll.visible = false
    end if
    does not work, BUT..
    if not mcore.uftileset = "sZ_CustomerPlan" then
         ctrlZ_BTNPreviewAll.visible = false
    end if
    ..does work
    can you spot the difference?:)
    apparently it HAS to be a little s
    just glad its working now, i put it in the beforeload like you suggested, thx for the tip
    cheers,
    Maarten

Maybe you are looking for

  • How do I stop my panels from being visible while in InDesign CS5's presentation mode?

    Hey there, I have a quick question... So when I'm not working with two monitors I sporadically have this problem where when I enter InDesign CS5's (on a Mac) presentation mode (shift W) all of my panels (color, pages, swatches, pathfinder etc) are vi

  • Help needed in connecting a Mac Mini to AT&T DSL

    Any suggestions on how to troubleshoot this problem will be appreciated. I'm helping a friend connect a Mac to the Internet using AT&T DSL. The computer is a Mac Mini, 1.42 GHz PPC G4, running OS X 10.5. It is connected by Ethernet to an AT&T DSL mod

  • How do i map from file name to the device it resides on

    hi i need to find a way to map from a file name to the disk device it resides on( so i can do ioctl to that device ). i know that stat(2) returns a dev_t value, but i don't know how to translate from that dev_t to the device name( e.g. /dev/dsk/c0d0.

  • How do I change DHCP range other than standard options

    Recently I discoverd that the settings of the DHCP range of my Time Capsule changed after an update. Through my provider we have received a DHCP-range so I can access the disks remote via BTMM. Due the the internal fiber network it was necessary to a

  • CoreMIDIserver and FCP interaction

    Hello, I seem to be having two problems with Soundtrack Pro. First is that every time I open STP, coreMIDIserver.framework also opens. It seems to freeze every time and freezes STP at the same time. I'm not using any MIDI in my STP project, so I don'