Making new Images

Im making a game and when you click a button and then click on the screen it makes a new tower. At first when you click the tower will show up where you clicked, but if you try to make a second tower and you click on the screen the first tower is deleted and the second tower is drawn where you clicked. I know why it dose this and I know how I COULD fix it but it would take a lot of programming and I would only be able to make a certain amount of towers. So I was wondering how can I fix it so that it wont delete the first tower?
Here is the code that I have so far:
import java.awt.Color;
import java.awt.Container;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Defense extends JPanel implements MouseListener{
     Timer update;
     static JFrame dframe = new JFrame("Battle!");
     static BufferedImage map1,rgtower;
     static JButton regtower = new JButton();
     static ImageIcon rgticon = new ImageIcon("imgs/rgtower.png");
     static boolean placetower,drawtower,drawwarning = false;
     static Graphics g;
     Font font = new Font("Arial",Font.PLAIN,30);
     int x,y = 0;
     static Container dcontain = dframe.getContentPane();
     public static void defGUI(){
          dcontain.add(regtower);
          dcontain.add(new Defense());
          regtower.setBounds(645,100,100,50);
          regtower.setIcon(rgticon);
          regtower.setBorder(null);
          regtower.setFocusable(false);
          regtower.addActionListener(new buttonlist());
          dframe.setSize(800,600);
          dframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          dframe.setResizable(false);
          dframe.setVisible(true);
          try {
               map1 = ImageIO.read(new File("imgs/map1.png"));
               rgtower = ImageIO.read(new File("imgs/rgtower.png"));
          } catch (IOException e) {
               e.printStackTrace();
     public void paintComponent(Graphics g){
          super.paintComponent(g);
          g.drawImage(map1,0,0,null);
          if(drawwarning == true){
               g.setFont(font);
               g.setColor(Color.black);
               g.drawString("Cant Place it there!",300,50);
          g.create(x, y, 40, 40);
          g.drawImage(rgtower,x,y,40,40,null);
     public Defense(){
          UTimer task = new UTimer(this);
          update = new Timer();
          update.scheduleAtFixedRate(task,0,5);
          this.addMouseListener(this);
          this.setOpaque(false);
          dframe.repaint();
          System.gc();
     class UTimer extends TimerTask{
          private Defense def;
          public UTimer(Defense def){
               this.def = def;
          public void run(){
               def.repaint();
               dcontain.repaint();
     public void mouseClicked(MouseEvent e) {
          if(placetower == true){
               if(e.getX() >= 590){
                    drawwarning = true;
               }else{
                    drawwarning = false;
                    placetower = false;
                    x = e.getX()-25;
                    y = e.getY()-25;
     public void mouseEntered(MouseEvent arg0) {}
     public void mouseExited(MouseEvent arg0) {}
     public void mousePressed(MouseEvent arg0) {}
     public void mouseReleased(MouseEvent arg0) {}
}

BigDaddyLoveHandles wrote:
That wasn't that hard, was it? An array would work, but a list would be easier, wouldn't it?Oh well im not sure how to use a list but I could figure it out. Thanks for the help! Could you give me a sample code that would get that to work? You don't have to though lol.

Similar Messages

  • How to expand an Image without making new image

    Well, I got a VolatileImage(or it can be normal image), I wanna cut a portion of it, then attach something new to the portion, how do I do so?
    See the following:
    Image:
    111111
    222222
    222222
    I want to cut the "2s" part, so I get
    222222
    222222
    Then attach "3s" to the bottom:
    222222
    222222
    333333
    The way I can think of is: make a new VolatileImage with the right size (portion size+ new attachment size), cut the portion from the old image, paste the cut into the new image at the right position, then render the new attachments into the new image, but this way requires a lot of memory copying, is there a directly way just chop off unwanted stuff and put in new stuff?
    Thanks in advance.

    What kind of application are you trying to do this for? If you're scrolling a map, a better way to do it is to split your original (big) map image file into small square tiles and just draw the one that are on the screen at a given time. This way, instead of copying a large image whenever you scroll, you just change some x and y variables and draw the images at a new offset.

  • Canceled making a new image in Disk Utility, lost hard drive space

    Hi,
    I was creating a new image (12 gigs) and during the process of creating it, the bar was no longer moving (for over an hour) so i canceled the process (it got a about 1/4 of the way through). But now it seems I missing about 3 gigs of space on my hard drive. It seems when it got canceled, it didnt remove it all the way. Is there a way to fix this?
    Thanks

    I restarted the computer, and it did not change. I ran all the terminal commands on that website, but nothing fishy came up. After i ran the disk usage command (sudo du -cxhd 1 /) it totalled up to 51 gigs of data. I have an 80 gig HD (79.68gigs) which should leave 29 gigs available. Finder says i have 24.17 gigs available, so I am missing some. maybe this is virtual memory being used? It seems like it happened after the image though. Thanks

  • Using disk utility to burn new image dvd's

    Ok I just learned to burn DVD'd using Disk Utility and New image.
    But I have come to halt in my burning with a new issue.
    My issue is that I have a file that is 4.63GB. When I make a new image so that I can burn it, it increases the size of the file(Video TS) to 5.13GB. Making it to big for a 4.7GB DVD.
    My question is is this normal for the new image file to increase in size, and is there a way for me to stop this from happening. Or can anyone give me any other suggestions. Please help.

    Ok I have never tried that, as this is the first time it is suggested to me.
    The reason i have been doing it via DU, is because this has been to only way to get it to play on
    home DVD player and burn with the UDF setting. I was told to do it this way when I was trying to burn
    copies of my nieces fifteens that was prof. done on a DVD.
    I am trying to burn a copy of a movie so that it can be played on home dvd players. Yes I have done this before and the copies I burned via DU/new image, worked perfectly. And the ones I burned by just choosing file and burning it did not work.
    So any help would be great.

  • "Authentication error", making disk image

    I'm trying to make a disk image of my OS X boot disk, as an emergency backup. I'm booting from the Installation CD that came with my Mac Pro, and using Disk Utility. I select my boot drive, click New Image, and tell it to save to an external firewire drive, compressed and encrypted. It starts and quickly errors out, with "Authentication error." What does this mean?
    I've used 250 GB of the 500 GB on my boot drive, and my external drive is 120 GB. I'd rather tell it to skip some files to save space, but it doesn't give me the option to do that. Will "compress" get it to be small enough? Is this why I'm getting an error? I've repaired permissions before booting from the CD.

    I don't know about the authentication error; however, to make a disk image of 250 GB source drive to a 120 GB target is an exercise in futility. There's not enough room. 250 GB? What are storing? A complete music store, the movies of Hollywood, or the pictures in an art gallery?
    If you want an emergency backup of your 500 GB HD, then you'll need an external at least as big. BTW, making disk images for this purpose is fraught with danger since you can't ensure that it's good until you restore it to a bootable HD. I strongly recommend something like Carbon Copy Cloner, SuperDuper!, etc. instead. BTW, you can just drag & drop any data files from one HD to another. There's no need to put them in a disk image and certainly no need to encrypt things. If you decide to go the bootable backup route, move the data files to root-level and don't back those up. That should make your emergency backup a lot smaller.

  • Disk Utility Freeze when using New Image

    Has anybody experienced the following?:
    my system:
    Brand new Mac Pro 8-core 2.66GHz
    24GB RAM
    Snow Leopard 10.6.3 freshly installed
    Apple SuperDrive DVD
    I am in the process to install a lot of software and I like to make Disk Image of the software DVD to make things quicker to install.
    Now what happens is that as soon as I select New Image from Disk Utility (after selecting the DVD on the left menu), the New Image progress window appears and then Disk Utility freezes. The disk image is being created in the background, but the progress window DOES NOT show the disk image status and eventually I have to OPTION-APPLE ESC from Disk Utility.
    What I have tried is:
    . delete plist for Disk Utility in Preferences
    . repair permissions in SAFE BOOT mode
    After that Disk Utility/New Image will work the first time as expected, and then the next time I am getting the same problem.
    Any ideas what I could try to diagnose/fix this problem?
    Thank you!

    Thanks for your feedback.
    As far as making a disk image or not, yes it takes some times to create it... longer? I am not sure because when you install a software there is a back and forth reading/writing, whereas when you create your disk image it does the reading and writing in a linear fashion... anyway to me the big benefit is when you have more than one disk part of an install (Apple FCS, Adobe CS, etc...) once you have created all your disk image, it will install everything automatically without having to feed each disc... and usually I have to do a fresh install later on... and finally it gives you a backup of your software...
    Thanks again.

  • DW can't find new image?!

    Hi all,
    I'm making changes in a website using DW, which include
    adding some new images. I edited the image using photoshop and move
    them into the file where all the images for the website are.
    Strange thing is the new images appear in the assets (also other
    places while I was trying to insert them into the page), but
    there's no preview and when I click insert, the image appears
    broken in DW.
    I tried anyway to upload the page, together with all
    dependent files. The new image appear broken online too.
    Weird thing is this seems only affect new images, the old
    ones on the page are unaffected?!
    Can anybody help me?
    Thanks a million!

    > Is it better to insert an image from outside the site
    folder, then DW ask
    > me
    > to save it inside the site folder, or move all the
    necessary images under
    > the
    > site folder and link it in DW from there (as i've always
    done)?
    Makes no difference. If you have defined a default images
    folder, DW will
    copy it there without prompting.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "eidolonx" <[email protected]> wrote in
    message
    news:gp417t$o4v$[email protected]..
    > After hours of trying, I finally 'solved' the problem by
    coverting the
    > .jpg
    > files into .png. I still don't understand why the old
    one (jpg) are fine,
    > but
    > not the new ones.
    >
    > Is it better to insert an image from outside the site
    folder, then DW ask
    > me
    > to save it inside the site folder, or move all the
    necessary images under
    > the
    > site folder and link it in DW from there (as i've always
    done)?
    >
    > Thanks everyone who replied me. :)
    >

  • Lenovo G530 making an image

    I want to install XP on my new G530 but before I do I want to close the drive incase for some reason I need to revert back to Vista. DOes anyone have experience with this? Any suggestions
    Thanks

    how would I go by making an image of a disc(age of empires II) so that I dont have to keep inserting the disk in.
    The application you need is Drive-In. It can be obtained from
    http://www.flip4mac.com/drivein.htm
    It is currently available as a free beta, which works just fine.
    This does precisely what you want. Giving you this information does not contravene the terms of use of this forum. I will explain:
    Drive-In has one use only: it makes a disk image of any DVD, including commercial copy protected ones, so that you can store the DVD on your hard disk for playback only. You will not be able to copy it, or burn a DVD from it, as it preserves the copy protection on the DVD it makes the disk image from. It is for convenience only. For full details refer to the above link.
    Message was edited by: Klaus1

  • DISK UTILITY -- "New Image" problems

    Maybe I don't get how this works. I used an external USB drive to back up my MacBook Pro, making an image un=sing Disk Utility "New Image." THis seems to have worked fine. When I attach the external drive and double click on the DMG file it open and I seem to have access to all contents.
    Today I tried to make a second "New Image" on the same drive of my iMac24" and everything runs and makes a DMG file, but when I click on this one I get a msg saying the disk image "couldn't be opened" with the reason given being "no mountable file systems."
    Does this make perfect sense to somebody?
    Have I completely misunderstood the use and practice of the "new image" in Disk Utility?
    Thanks.

    Hey. If you want to make a DMG image of your iMac, you will need to boot off the install DVD and use Disk Utility from the DVD. To create the DMG is the same process: Select the "Macintosh HD" icon on the left hand side list of Disk Utility, click the "New Image" button, leave "Image Format" as "Compressed" and its up to you for Encryption, I always leave it as "None".
    Select to save your DMG image on the external hard drive and click save. Once the image is done, click on "Image" on the menu bar and click on "Scan Image for Restore...".
    That's it!
    Good luck

  • How do I add a new Image to the Web App Module Portfolio after I went Live?

    Im pretty new to web building and I push a site live for my client and they want me to constantly update the site with new images but I cant seem to add or change any of the pics in portfolio or in carousel. Can someone help me please...

    Hi,
    Can you provide an example? So we can have a look of your existing set-up and help point you in the right direction to help update these images.
    Kind regards,
    -Sidney

  • HT5622 I was making new Apple ID with my other Email on iTunes, but I canceled the process on payment page. After a while i went to make a new ID with same Email but it says the Email is already in use! what should i do?

    I was making new Apple ID with my other Email on iTunes, but I canceled the process on payment page. After a while I went to make a new ID with same Email but it says the Email is already in use! what should i do?

    You will need to try changing the email address on the first account and see if you can then re-use it on a new account - you can try changing the email address via http://appleid.apple.com or by logging into it via the Store > View Account menu option on a computer's iTunes (if you don't have a spare email account then you can create one via http://gmail.com or http://hotmail.com)

  • I am used to that when I open an image in Bridge it will be opened in PS, with all preferenses I have done to the image. Now it opens in PS but without any changes i have don e in Bridge. Also when I open a new image I want it to be opened in Camera Raw a

    I am used to that when I open an image in Bridge it will be opened in PS, with all preferenses I have done to the image. Now it opens in PS but without any changes i have don e in Bridge. Also when I open a new image I want it to be opened in Camera Raw automatically, both if a Jpeg or Raw picture.
    Using PS CC
    Regards BOJ

    <moved from Adobe Creative Cloud to Bridge General Discussion>

  • "input/output error' when making disc image from DVD

    I've had problems installing Logic, and a Pro Apps Genius at Applecare suggested I try making an image of the problematic DVD (Audio Content 1) and then trying an install that way.
    While I can make an image of the Install disc to my desktop fine, the Audio Content 1 disc reports an "input/output error".
    This means I'm unable to copy the disc and then successfully install my Logic Studio.
    Any ideas?

    Thanks for your answer.
    Yes, I thought that might be the case - but I'd taken my Mac and Logic disks to a Genius bar, and the 'Genius' had said he'd fixed the issue. I just wish he'd explained what he did and why he didn't replace the faulty disk(s)!
    But is there any way around having the claim a disk, now I'm living abroad and my 'warrantee' has run out? It's going to be a pain in the fundament trying to claim a replacement set.

  • After creating a new image of my project burned from iDVD I get no audio when I import it back into iMovie HD 6.0.3

    I need to edit my project after I have already burned the project. I deleted the files after being burned to save space on my hard drive. So I made a new image of the burned project with disk utility. I opened up iMovie HD 6.0.3 and imported the movie but I get no audio and the audio folder for new disk image doesn't have anything in the folder. Any help is greatly appreciated!!!

    You need to convert the VOB files in the TS-Folder of the DVD back to DV which iMovie is designed to handle. For that you need mpegStreamclip:
    http://www.apple.com/downloads/macosx/video/mpegstreamclip.html
    which is free, but you must also have the  Apple mpeg2 plugin :
    http://www.apple.com/quicktime/mpeg2/
    which is a mere $20.
    Another possibility is to use DVDxDV:
    http://www.dvdxdv.com/NewFolderLookSite/Products/DVDxDV.overview.htm
    which costs $25.
    For the benefit of others who may read this thread:
    Obviously the foregoing only applies to DVDs you have made yourself, or other home-made DVDs that have been given to you. It will NOT work on copy-protected commercial DVDs, which in any case would be illegal.

  • Disk Utility can't repair disk...Can I still create a new image to back up?

    Two days ago my computer died and I haven't been able to get past the Apple screen since. I've tried starting in Safe mode, etc. that did not work. I just started up using my installation disk and got into Disk Utility. It says it cannot repair the disk and that I should back up as many files as possible and reformat the disk.  How am I supposed to back up if I can't start up? I am currently creating a new image of the HD to an external drive but my question is if Disk Utility couldn't repair the disk, with the external drive copy also be problematic? How can I tell before I reformat the whole thing and start over?
    Please help someone! I am in a little over my head!
    Thanks

    I am currently creating a new image of the HD to an external drive but my question is if Disk Utility couldn't repair the disk, with the external drive copy also be problematic?
    Maybe.
    How can I tell before I reformat the whole thing and start over?
    Run Repair Disk on the copy.

Maybe you are looking for

  • External hard drive nightmare

    Hi all, first time posting but this site has helped me several times in the past so thank you for that, Having an absolute nightmare with an external drive. I've got a Hitachi Touro Pro 4TB USB 3.0 that recently had some trouble with the power supply

  • Could not find key?

    I have tried to upgrade Itunes, but everytime I do it comes back saying it cannot be installed & that it needs QuickTime. But when I try to download QuickTime, it claims that it could not open key(?) I've even uninstalled Itunes completely, but it st

  • Restricting Transfer Posting for Reserved Stock

    Dear Gurus, I have a scenario that the user should not be allowed to transfer material (SLoc to SLoc) that has been reserved. At the moment the system is allowing without any warning or error. Is it possible and do I have to configure any settings fo

  • AIR for Android App - Video Issue

    Hi all, I've developed a Air for Android application targeted specifically for Samsung N 800. There is a section in the application that has a list of Thumbnails and the user can click on any thumbnail and Play appropriate video. When playing the vid

  • BW G3 Down after Security Updates

    I have an older BW G3 that's running some version of 10.1 or something close to that. We just use it to run a scanner. After running a few minor OS updates that included a security update and something else, I have a system that boots up, but doesn't