I need some help with my java game using applets, CAN SOMEBODY PLEASE HELP

Hi,
I am in the process of creating a RPG program using Java. I am not very experienced with java, however the problem i am currently facing is something i can't seem to figure out. I would like to draw a simple grid where a character (indicated by a filled circle) moves around this grid collecting items (indicated by a red rectangle). When the character moves on top of the grid with the item, i would like it to disappear. Right now i am not worrying about the fact that the item will reappear after the character moves away again, because sometimes, when the character moves over the item, nothing happens/another item disappears. i have been at this for 4 days and still cannot figure out what is goign on. can somebody please help me? it would be most appreciated.
Thanks
PS if i needed to send you my code, how do i do it?

Thank you for replying.
The thing is, I am taking java as a course, and it is necessary for me to start off this way (this is for my summative evaluation). i agree with you on the fact, however, that i should go in small steps. i have been doing that until this point, and my frustration caused me to jump around randomly for an answer. I also think that it may just be a bug, but i have no clue as to how to fix it, as i need to show my teacher at least a part of what i was doing by sometime next week. Here is my code for anybody willing to go through it:
// The "Keys3" class.
import java.applet.*;
import java.awt.*;
import java.awt.Event;
import java.awt.Font;
import java.awt.Color;
import java.applet.AudioClip;
public class Keys3 extends java.applet.Applet
    char currkey;
    int currx, curry, yint, xint;
    int itmval [] = new int [5],
        locval [] = new int [5],
        tempx [] = new int [5], tempy [] = new int [5],
        tot = 0, score = 0;
    boolean check = true;
    AudioClip bgSound, bgSound2;
    AudioClip hit;
    private Image offscreenImage;
    private Graphics offscreen;     //initializing variables for double buffering
    public void init ()  //DONE
        bgSound = getAudioClip (getCodeBase (), "sound2_works.au");
        hit = getAudioClip (getCodeBase (), "ah_works.au");
        if (bgSound != null)
            bgSound.loop ();
        currx = 162;
        curry = 68;
        setBackground (Color.white);
        for (int count = 0 ; count < 5 ; count++)
            itmval [count] = (int) (Math.random () * 5) + 1;
            locval [count] = (int) (Math.random () * 25) + 1;
        requestFocus ();
    public void paint (Graphics g)  //DONE
        resize (350, 270);
        drawgrid (g);
        if (check = true)
            pickitems (g);
            drawitems (g);
        g.setColor (Color.darkGray);
        g.fillOval (currx, curry, 25, 25);
        if (currkey != 0)
            g.setColor (Color.darkGray);
            g.fillOval (currx, curry, 25, 25);
        if (collcheck () != true)
            collision (g);
        else
            drawitems (g);
    } // paint method
    public void update (Graphics g)  //uses the double buffering method to overwrite the original
                                     //screen with another copy to reduce flickering
        if (offscreenImage == null)
            offscreenImage = createImage (this.getSize ().width, this.getSize ().height);
            offscreen = offscreenImage.getGraphics ();
        } //what to do if there is no offscreenImage copy of the original screen
        //draws the backgroudn colour of the offscreen
        offscreen.setColor (getBackground ());
        offscreen.fillRect (0, 0, this.getSize ().width, this.getSize ().height);
        //draws the foreground colour of the offscreen
        offscreen.setColor (getForeground ());
        paint (offscreen);
        //draws the offscreen image onto the main screen
        g.drawImage (offscreenImage, 0, 0, this);
    public boolean keyDown (Event evt, int key)  //DONE
        switch (key)
            case Event.DOWN:
                curry += 46;
                if (curry >= 252)
                    curry -= 46;
                    if (hit != null)
                        hit.play ();
                break;
            case Event.UP:
                curry -= 46;
                if (curry <= 0)
                    curry += 46;
                    if (hit != null)
                        hit.play ();
                break;
            case Event.LEFT:
                currx -= 66;
                if (currx <= 0)
                    currx += 66;
                    if (hit != null)
                        hit.play ();
                break;
            case Event.RIGHT:
                currx += 66;
                if (currx >= 360)
                    currx -= 66;
                    if (hit != null)
                        hit.play ();
                break;
            default:
                currkey = (char) key;
        repaint ();
        return true;
    public boolean collcheck ()  //DONE
        if (((currx == tempx [0]) && (curry == tempy [0])) || ((currx == tempx [1]) && (curry == tempy [1])) || ((currx == tempx [2]) && (curry == tempy [2])) || ((currx == tempx [3]) && (curry == tempy [3])) || ((currx == tempx [4]) && (curry == tempy [4])))
            return false;
        else
            return true;
    public void collision (Graphics g)
        drawgrid (g);
        for (int count = 0 ; count < 5 ; count++)
            if ((currx == tempx [count]) && (curry == tempy [count]))
                g.setColor (Color.darkGray);
                g.fillOval (currx, curry, 25, 25);
            else if ((currx != tempx [count]) && (curry != tempy [count]))
                g.setColor (Color.red);
                g.fillRect (tempx [count], tempy [count], 25, 25);
    public void drawitems (Graphics g)
        for (int count = 0 ; count < 5 ; count++)
            g.setColor (Color.red);
            g.fillRect (tempx [count], tempy [count], 25, 25);
    public void pickitems (Graphics g)
        check = false;
        for (int count = 0 ; count < 5 ; count++)
            if (locval [count] <= 5)
                tempy [count] = 22;
            else if (locval [count] <= 10)
                tempy [count] = 68;
            else if (locval [count] <= 15)
                tempy [count] = 114;
            else if (locval [count] <= 20)
                tempy [count] = 160;
            else if (locval [count] <= 25)
                tempy [count] = 206; //this determines the y-position of the item to be placed
            if (locval [count] % 5 == 0)
                tempx [count] = 294;
            else if ((locval [count] == 1) || (locval [count] == 6) || (locval [count] == 11) || (locval [count] == 16) || (locval [count] == 21))
                tempx [count] = 30;
            else if ((locval [count] == 2) || (locval [count] == 7) || (locval [count] == 12) || (locval [count] == 17) || (locval [count] == 22))
                tempx [count] = 96;
            else if ((locval [count] == 3) || (locval [count] == 8) || (locval [count] == 13) || (locval [count] == 18) || (locval [count] == 23))
                tempx [count] = 162;
            else if ((locval [count] == 4) || (locval [count] == 9) || (locval [count] == 14) || (locval [count] == 19) || (locval [count] == 24))
                tempx [count] = 228;
    public void drawgrid (Graphics g)  //DONE
        g.drawRect (10, 10, 330, 230); //draws the outer rectangular border
        int wi = 10; //width of one square on the board
        int hi = 10; //height of one square on the board
        for (int height = 1 ; height <= 5 ; height++)
            for (int row = 1 ; row <= 5 ; row++)
                if (((height % 2 == 1) && (row % 2 == 1)) || ((height % 2 == 0) && (row % 2 == 0)))
                    g.setColor (Color.gray);
                    g.fillRect (wi, hi, 66, 46);
                else /*if (((height % 2 == 0) && (row % 2 == 1)) || ((height % 2 == 0) && (row % 2 == 0)))*/
                    g.setColor (Color.lightGray);
                    g.drawRect (wi, hi, 66, 46);
                    g.setColor (Color.lightGray);
                    g.drawRect (wi, hi, 66, 46); //drawn twice to make a shadow effect
                wi += 66;
            wi = 10;
            hi += 46;
        } //this draws the basic outline of the game screen
} // Keys3 class

Similar Messages

  • I need help with XML Gallery Fade in out transition. somebody please help me :(

    I need help with XML Gallery Fade in out transition. somebody please help me
    I have my post dont want to duplicate it

    The problem doesn't lie with your feed, although it does contain an error - you have given a non-existent sub-category. You need to stick to the categories and sub-categories listed here:
    http://www.apple.com/itunes/podcasts/specs.html#categories
    Subscribing to your feed from the iTunes Store page work as such, but the episodes throw up an error message. The problem lies with your episode media files: you are trying to stream them. Pasting the URL into a browser produces a download (where it should play the file) of a small file which does not play and in fact is a text file containing (in the case of ep.2) this:
    [Reference]
    Ref1=http://stream.riverratdoc.com/RiverratDoc/episode2.mp3?MSWMExt=.asf
    Ref2=http://70.33.177.247:80/RiverratDoc/episode2.mp3?MSWMExt=.asf
    You must provide a direct link to the actual mp3 file. Streaming won't work. The test is that if you paste the URL of the media file (as given in the feed) into the address bar of a browser it should play the file.

  • Error message 1202 is preventing me from using itunes can somebody please help ?

    Error message 1202 is preventing me from using itunes can somebody please help

    Have you tried restarting the iPad? You will more than likely be starting over again with the setup process but you may be able to use the "later" option if you start all over again.
    Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.

  • HT204053 Need A Solution With An iCloud Problem So Can Somebody Please Help Me?

    Can somebody please help me find a solution to my problem? 
    When I enter my username and password and hit enter I get this message, "The Apple ID is valid but is not an iCloud account" is the error message I receive implying that I do not have an iCloud account. I have searched and looked at the troubleshooting contents and I haven't found anything even close to this issue so I have come here for help. I appreciate any tips or tricks to fix my problem.    Thank you for reading and look forward to hearing your answers. 
    Thank You,
    Lisa W. 

    Hey Lisa_AW!
    If you want to make this Apple ID an iCloud account, try referencing the information here:
    Creating an iCloud account: Frequently Asked Questions
    http://support.apple.com/kb/ht4436
    Thanks for using the Apple Support Communities. Have a good one!
    -Braden

  • I'm having trouble with my macbook pro, I have only had it for three months, when I plugged a camera sd card into the sd slot it isn't appearing anywhere on the computer and i can not access my photographs. can somebody please help me?

    I'm having trouble with my macbook pro, I have only had it for three months, when I plugged a camera sd card into the sd slot it isn't appearing anywhere on the computer and i can not access my photographs. can somebody please help me?

    Shootist007 wrote:
    Clifton I must disagree with you on the above statement. It is my opinion and experience that you should never connect the camera directly to any computer, Mac Windows Whatever.
    It is always best to Remove the memory card from the camera and put it in a card reader, whether an external reader or one built into the computer, to copy images from the card.
    Hi Shootist. I would be interested in hearing some reasoning on this. I almost always use a USB cable to connect my camera to the MBP for transferring pictures, and have moved about 30,000 this way over the last 6 years since my photography went digital. Recently, on the rare occassions when I have only a few to transfer and I was too lazy to go for the cable, I have used the card reader; about half those times I have difficulty getting the MBP to recognise the card. I find I have to press the card very hard into the slot for it to be recognised.
    My rationale is quite possibly wrong, but I feel that the USB connectors are more robust and hard-wearing than the flimsy connectors on an SD card. Also, I haven't measured it, but I think the data transfer is faster with the cable. (I just came across this test, which reports noticeably faster transfer for cable than built-in card reader, but the computer was a PC)
    Chiara, sorry for hijacking your thread.

  • I have a Steinberg MI4 and a Roland Fantom X7, and am trying to use my Fantom in Logic to record audio. Need help setting it all up using MIDI cables. Please help !

    I have a Steinberg MI4 and a Roland Fantom X7, and am trying to use my Fantom in Logic to record audio. Need help setting it all up using MIDI cables. Please help !

    Encryption wouldn't matter except for Wifi.
    While 10.2 might help, there's not much you can do on the Internet these days with less than 10.4.11
    Tiger Requirements...
    To use Mac OS X 10.4 Tiger, your Macintosh needs:
        * A PowerPC G3, G4, or G5 processor
        * Built-in FireWire
        * At least 256 MB of RAM (I recommend 1GB minimum)
        * DVD drive (DVD-ROM), Combo (CD-RW/DVD-ROM) or SuperDrive (DVD-R) for installation
        * At least 3 GB of free disk space; 4 GB if you install the XCode 2 Developer Tools  (I recommend 20GB minimum)
    http://support.apple.com/kb/HT1514
    http://www.ebay.com/sch/i.html?_nkw=mac+os+x+tiger+retail+10.4
    See Tom's, (Texas Mac Man), great info on where/how to find/get Tiger...
    https://discussions.apple.com/message/15305521#15305521
    Or Ali Brown's great info on where/how to find/get Tiger...
    http://discussions.apple.com/thread.jspa?messageID=10381710#10381710
    As far as Memory, that's sort of easy, find your eMac here...
    http://eshop.macsales.com/MyOWC/Models.cfm?Family=emac&sType=Memory
    As far as Hard Drive, it's not easy to replace the Internal drive, I'd maybe suggest an external Firewire drive to boot from...
    http://eshop.macsales.com/item/Other%20World%20Computing/MAU4S7500G16/

  • I just exchanged a faulty iPhone 4 for a new one, when I got home to restore it, iCloud says "cannot restore backup". Can somebody please help provide much needed advice? Thanks in advance!

    I just exchanged a faulty iPhone 4 for a new one, when I got home to restore it, iCloud says "cannot restore backup". Can somebody please help provide much needed advice? Thanks in advance!

    Yep, that's the only message that popped out. Nothing else. Yes, it's running on the latest ios and I still can't restore it. I called apple and they told me it's probably something wrong with their servers. Anyway thanks for the advice.

  • I set up my email account with ntlworld can somebody please help me why it keeps downloading emails i have deleted from about 4 years ago amounting to thousands of emails. thanks

    i set up my email account with ntlworld can somebody please help me why it keeps downloading emails i have deleted from about 4 years ago amounting to thousands of emails. thanks

    Hi, is this POP or IMAP?
    In Mail Preferences>Accounts>Mailbox Behaviors, what are settings for remove from server & such?

  • My IMessage says my sign in is incorrect, but then I go to the App Store sign out and sign back in and it works perfectly fine. I really need IMessage because I have a flip Phone which is so hard to text on so I like to use IMessage. Somebody please help

    My IMessage says my sign in is incorrect, but then I go to the App Store sign out and sign back in and it works perfectly fine. I really need IMessage because I have a flip Phone which is so hard to text on so I like to use IMessage. Somebody please help me;(

    Try:
    iOS: Troubleshooting FaceTime and iMessage activation

  • Can somebody please help-..with page ITEM

    Can somebody please help…..
    I have an Item named P11_FLAG on Page 11 of my application. I want to reference or access the value of this Item in all the pages of my application. I have tried several options but it seems not to work. I will really appreciate your help on this regard.
    Thank you

    referencing from other pages in code, use :P11_FLAG or external packages you can use the function v('P11_FLAG') or in substitution situations like referring to it in a report title &P11_FLAG. (note the last full stop).
    Phil

  • I am unable to update, uninstall, or reinstall iTunes on my laptop.  Windows 7 Ultimate 32 bits.  Error code is 2330.  Can somebody please help me?

    I am unable to update, uninstall, or reinstall iTunes on my laptop.  Everything was working fine until recently when there was an update available for iTunes, and when I tried to update this, I got the message, "The installer has encountered an unexpected error installing this package.  This may indicate a problem with this package. Error code is 2330."  Can somebody please help me?
    System configuration:
    Windows 7 Ultimate 32 bits.
    Version:  6.1.7601 Service Pack 1 Build 7601
    System Directory:  C:\Windows\system32
    RAM:  1.00 GB.

    For general advice see Troubleshooting issues with iTunes for Windows updates.
    The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down the page in case one of them applies.
    The further information area has direct links to the current and recent builds in case you have problems downloading, need to revert to an older version or want to try the iTunes for Windows (64-bit - for older video cards) release as a workaround for installation or performance issues, or compatibility with QuickTime or third party software.
    Your library should be unaffected by these steps but there are also links to backup and recovery advice should it be needed.
    tt2

  • When i open iphoto i see my photo's for 1 second and then they are gone .The photo's are still there but i can see them only on the bottom or top of my screen when i try to open them i get a sign that it is not possible.Can somebody please  help me?

    when i open iphoto i see my photo's for 1 second and then they are gone .The photo's are still there but i can see them only on the bottom or top of my screen when i try to open them i get a sign that it is not possible.Can somebody please  help me?

    Have you upgraded to iPhoto 9.6 for compatibility with Yosemite? If not, try that first.
    It looks like iPhoto has lost the connection between the thumbnails and the original image files.
    This can be caused by a corrupted iPhoto library, or the originals have been deleted or moved.
    Try first to rebuild your iPhoto Library:
    If you do not have a current backup of the iPhoto library, make a copy of the library, but do not overwrite any previous backup.
    Launch iPhoto with the ⌥⌘-key combination (option-command) held down.
    Select "rebuild" from the first aid panel.  This may take a while for a large library.
    Can you now see your photos again?
    If not, rebuild the library with iPhoto Library manager as described by Old Toad:            Re: iphoto crashed

  • I just want to know that if I buy an iphone 4S here in melbourne can i use it in china? i don`t know whether it`s locked or not and i don`t know what`s the network in china as well. Can somebody please help?I am really in a hurry to know it. Thanks a lot.

    I just want to know that if I buy an iphone 4S here in melbourne can i use it in china?
    i don`t know whether it`s locked or not and i don`t know what`s the network in china as well.
    Can somebody please help?
    I am really in a hurry to know it.
    Thanks a lot.
    P.S: For the iphone 4S. is there any difference for the one from online shop or the actual store?

    iPhones purchased from the online Apple Store in Australia will be unlocked. To the best of my knowledge, unlocked iPhone are not available from the physical Apple Stores at this time, though you can call the Apple Store in Melbourne and inquire.
    Note that the warranty on iPhones is not international, so if you purchase an iPhone in Australia and it needs service, you would have to ship the iPhone to someone in Australia to take or send to Apple for service and then ship it back to you.
    Regards.
    (Note for any readers: this is an old thread and I posted before noticing the date, but decided to leave my reply in case anyone else finds the thread and has the same question).

  • I have a ram problem, can somebody please help me?

    Hello
    This is the first time I've put a computer together from scratch (I got some help from a friend though). What I wonder is if there is a manual for the MSI mothercards somewhere on the net because I didn't get any good description  in the package, and I can't find the spot for audi and USB inputs. I also would like to know how many memorysticks i can use, because if i put in 3 of them the computer starts to beep. Can somebody please help me?
    My specs are:
    Q-tec midi Tower
    MSI K8N Neo2-FX, nForce3
    AMD Athlon 64 3200+ 2.0GHz socket 939
    Zalman P4 CNPS-7700-CU
    XFX Geforce FX5500 128MB DDR
    Samsung Spinpoint P120 200GB
    Sony DVD burner DL
    Sony floppydisk
    Cosair Value S. PC3200 DDR-dimm 512MB unbuffered non-Parity, 64Meg x 64, CL2.5
    (I have 3 of these but I can only have 2 at a time or the computer wont work)
    // TheGamecritic

    Quote from: TheGamecritic on 15-September-05, 18:42:56
    Hello
    This is the first time I've put a computer together from scratch (I got some help from a friend though). What I wonder is if there is a manual for the MSI mothercards somewhere on the net because I didn't get any good description  in the package, and I can't find the spot for audi and USB inputs. I also would like to know how many memorysticks i can use, because if i put in 3 of them the computer starts to beep. Can somebody please help me? 
    My specs are:
    Q-tec midi Tower
    MSI K8N Neo2-FX, nForce3
    AMD Athlon 64 3200+ 2.0GHz socket 939
    Zalman P4 CNPS-7700-CU
    XFX Geforce FX5500 128MB DDR
    Samsung Spinpoint P120 200GB
    Sony DVD burner DL
    Sony floppydisk
    Cosair Value S. PC3200 DDR-dimm 512MB unbuffered non-Parity, 64Meg x 64, CL2.5
    (I have 3 of these but I can only have 2 at a time or the computer wont work)
    // TheGamecritic
    Congrats on 'Rolling your Own' for the first time.  I'm certainly no expert although I have sucessfully built a few.  Actually, my specs are almost identical except I'm using Kingston Value Ram instead of Cosair.  As far as your first question, I assume you mean the internal USB/MB connectors and the MB audio connector(s).  The information is in the MSI Neo2 Plat manual although you have to look closely and move back and forth between the MB schemaic and the section(s) describing the connections to get a clear fix.  The MB USB connectors are on the side of the MB furthest from the RAM slots and about in the center, (JUSB1 or JUSB2).  The audio connector (JAUD1 is located on the same side of the MB as the USB connectors only near the rear panel end, (close to the orange PCI slot).  As you, I found that that I could not use three ram sticks as I could in my old K7 board and when I bought two sets of matched ram I found that it didn't like 4 sticks either.  Three:  Would'nt post  Four:  Instability and an initial  hit in performance;  although I was able to finally coax it to 200mhz Dual Channel it wasn't worth it because of the random crashes n Windows I was getting. I have also discovered the hard way that for some reason my board at least is hypersensitive to IDE  cables, (Would not recognize any secondary IDE device on Channel 1 until I found the right cable) and it does not like Sound Blaster audio cards prior to Audigy 2 ZS.  Actually, it only tolerates a ZS and I had problems and it didn't like my new X-Fi at all until I moved it to the PCI slot closest to my video card.  I was getting random BSODS and crashes, (one that took out my OS).  Since I move the card things appear to be more stable, so far.  Anyway good luck.

  • Can somebody please tell me what 'genius' included 'family' in reminders, and, made it so i cannot remove it.  I have NO family, and, i find this particularly hurtful and disrespectful.  Can somebody please help me remove it.

    Can somebody please tell me what 'genius' included 'family' in reminders, and, made it so i cannot remove it.  I have NO family, and, i find this particularly hurtful and disrespectful.  Can somebody please help me remove it.

    Hi EmmeElle,
    Is it an iCloud reminder or a third party reminder like from an Exchange account(maybe your company provides this service together with mail etc..).
    In the first case you should definitely be able to delete it by right click->delete or via https://www.icloud.com
    In the second case there might be a browser based settings page from your company or the provider of the service (i.e. Exchange) itself. Otherwise you can go to your System Preferences -> Internet Accounts and deactivate reminders for this account. WARNING: this also deletes all other reminder lists and reminders from this service on your mac.
    jl

Maybe you are looking for

  • How do I open a scanned picture in Firefox?

    <blockquote>Locking duplicate thread.<br> Please continue here: [[/questions/858927]]</blockquote> I have some pictures scanned and saved in my computer. How do I open one of them in Firefox? I'm trying to design a book cover and need to open a pictu

  • I have IPHONE 5s and my phone Bluetooth is not working its showing only its showing only searching for device but no results..?

    BLUETOOTH NOT WORKING SHOWING ONLY SEARCHING THE DEVICE BUT NO RESULT?

  • How to 'clear' file upload field in forms

    In a form I am designing I need a 'clear' or 'reset' button that clears the entire form. This is easy to do, of course, but alas my form has a file upload field, and in Safari I just can't get that field to go back to it's default empty state. is the

  • Mass blocking of vendor

    Hi Experts, My client asked to give acess for Mass blocking of vendor.(T.code: XK99). If I execute this t.code what is the impication. I want to do Postivie and negative testing. Please provide detailed info. Regards, Krishna

  • Problem with HDTV Playback

    Am trying to watch some shows I can't get in the uk on my Mac and they've been recorded as an HDTV format. I can see the shows but cannot hear anything. I have the Quicktime pro but am seriously puzzled as to why I can't hear anything...does anyone k