Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

my java is weak :P -- i need help :0)

Options
  • 15-05-2001 5:24pm
    #1
    Registered Users Posts: 2,281 ✭✭✭


    ok. so it time to annoy you all by starting another thread smile.gif

    i am making a 2d game, with a top down view.

    the applet is 500x500, but i want the area that you can run around in to be bigger (i have been trying to implement 1500x1500.

    i have been trying to get the camera to follow the player by:

    1) drawing the player at his current location (using the paint method)(what ever it may be , say (750,750),

    2) then copying the 500x500 which the player is the center of, and pasting it back at (0,0).

    this does not work as java does not draw outside the visible area, (ie, it only draws the player if he is at (<500, <500).

    for the last 3 days i have been tryong to fix this, my final attemt that drove me round the bent was:

    1) creating a new canvas, 1500x1500
    2) drawing the player on the canvas
    3) then trying to do this:

    Graphics map = mapCanvas.getGraphics();
    paint(map);

    it didnt work, and there is not assembly errors, so i dont know which part is not working.

    my question
    can anyone tell me how to draw from a Canvas to my applet? or any other way to make an invisible 1500x1500 area, and to copy a selection to my applet.

    its driving me insane

    [ ps, is this problem specific enough? :0) ]


Comments

  • Moderators, Music Moderators Posts: 1,481 Mod ✭✭✭✭satchmo


    I don't know if this'll work exactly the way you want to, but it should tongue.gif

    You're probably already using a double buffer for offscreen drawing, so try making the this offscreen image (the one created with Graphics.createImage()) size 1500x1500. Then when you finally draw to the applet with g.drawImage(offScreenBuffer, 0, 0, this), change the x and y coords to draw different areas of the offscreen image. For example, if you want to draw the bottom-right 500x500 pixels, use g.drawImage(offScreenBuffer, -1000, -1000, this).

    You might also want to look up the Graphics.setClip() method in the Java API, and clipping in general - it's very handy doing animation.

    Hope this helps.


Advertisement