Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 MOUSE CURSORS, help ?
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
TheHobbit




PostPosted: Thu Jan 15, 2009 10:51 pm   Post subject: MOUSE CURSORS, help ?

hey guys
i am trying to get an image where my mouse happens to be for a game.
im thinking cross hairs, since its a simple shoot 'em up.

i've already tried drawing a simple X by taking the mousepos and using it as t he X's origin points. the problem there is that its too laggy, the time taken to redraw gives the actual mouse enough time to move some place else

any suggestions ?
Sponsor
Sponsor
Sponsor
sponsor
S_Grimm




PostPosted: Fri Jan 16, 2009 8:40 am   Post subject: RE:MOUSE CURSORS, help ?

Are you double or triple buffering? Whats your FPS? Is there a delay in the program? are you Bottlenecking by having your code perform too many processes at one time?
TheHobbit




PostPosted: Fri Jan 16, 2009 8:37 pm   Post subject: Re: MOUSE CURSORS, help ?

mmkay , after all your suggestions, i tried to narrow down to what was causing the lag

a few things

a) delay at the end of the paint method, its set to a 1000 now, because the 'characters' need that time to respawn
b) since the background is an image, the drawn cursor doesn't even show up unless i don't draw the background.

since nothing can be done about the delay, i tried to make a separate paint method for the crossHair and run it in the graphids method , but that didnt really work,i dont even know if you can have 2 paint methods ( but it should be able to since i've used a double buffer before and thats a paint method ). maybe it has to do the way im putting it ?

code:


 public void crossHairs (Graphics g)
    {
        g.drawOval (mouseXPos - 25, mouseYPos - 25, 30, 30); // draws 'crosshair' - test stages

    }




    public void paint (Graphics g)
    {

  [syntax=""]crossHairs ();/syntax]// ERROR HERE, NO APPLICABLE OVERLOAD[
        posGenerator (); // calls the method that generates positions
        healthMeter (); // calls  the method that adjusts health meter status

        if (drawZombies)
        {

            //  g.drawImage (BACKGROUND, 0, 0, appWidth, appHeight, this); // commented out temp.
            g.drawImage (zombie1, randomPosx1, randomPosy1, iconLength, iconLength, this);   // draws zombie1 at a random pos
            g.drawImage (zombie2, randomPosx2, randomPosy2, iconLength, iconLength, this);   // draws zombie2 at a random pos


        }


        // main interface screen - bottom of screen where stats displayed

        g.setColor (Color.red);

        g.drawString ("Zombies Killed", 725, 595); // panel on side that shows user # of zombies killed
        g.drawImage (zombieDead, 765, 600, 65, 65, this);   // draws zombiesKilled image, shows a dead zombie w/ big X on it
        g.setFont (messageFontsize20);
        g.drawString (zombiesKilledScore+ " x ", 730, 650); // counter that deals with score


//... rest of drawing code goes here ....

//a delay at the end of the paint method is about here

  } // paint method ends here



im guessing the way i set up that method is wrong or something ? any ideas of how to work around that ?

p.s i also have a buffer problem if any one has a solution : adding a double buffer disables my mouse functions ,WHY ?
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: