Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


vastrolorde

Member Since 25 Apr 2013
Offline Last Active May 02 2013 01:40 PM

Topics I've Started

Passing custom objects to functions

02 May 2013 - 08:05 AM

I made a class for pixel perfect collision, but for it to work, i must send the entire object to it. How can i pass an entire object to a function. whati s the general name for objects, like integrals have int and so on. Or how can i send the specific part of the spritesheet to the function. Im using imageicon to draw the images on the board , adn all the movement and stuff is done with image icons.

So how to i send objects ingonito or how i send parts of imageicon?


strange error

02 May 2013 - 05:16 AM

C:\Users\Marko\Desktop\java>java rtype.RType
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at javax.swing.ImageIcon.<init>(Unknown Source)
        at rtype.Missile.<init>(Missile.java:21)
        at rtype.Craft.fire(Craft.java:106)
        at rtype.Craft.keyPressed(Craft.java:85)
        at rtype.Board$TAdapter.keyPressed(Board.java:228)
        at java.awt.Component.processKeyEvent(Unknown Source)
        at javax.swing.JComponent.processKeyEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
        at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)

        at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Sour
ce)
        at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Sour
ce)
        at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$000(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)

I get this error when i pres space in my game. I had a major screwup, i accidentally deleted the orginal .java files, but i recreated them. But for somereason shooting stopped working. Each time when i press space i get this message in console.


Hitbox on irregular objects

26 April 2013 - 10:08 AM

How to i create a hitbox for irregular objects.


Movement is clitchi and weird

26 April 2013 - 05:16 AM

public int getFrame(){
        
        if(aeg % 60 == 0){
            if(frame == 0){
                beforeframe = frame;
                frame +=1;
                }
        }
        if(frame != 0){        
            if(frame == 1){
                if(aeg % 30 == 0){
                    if(beforeframe == 0){
                        beforeframe = frame;
                        frame +=1;
                        }
                    if(beforeframe == 2){
                        beforeframe = frame;
                        frame -=1;
                        }
                }
            }
            else if(frame == 2){
                if(aeg % 30 == 0){
                    if(beforeframe == 1){
                        beforeframe = frame;
                        frame +=1;
                        }
                    if(beforeframe == 3){
                        beforeframe = frame;
                        frame -=1;
                        }
                    }
                }
            else if(frame == 3){
                if(aeg % 30 == 0){
                    if(beforeframe == 2){
                        beforeframe = frame;
                        frame +=1;
                        }
                    if(beforeframe == 4){
                        beforeframe = frame;
                        frame -=1;
                        }
                    }
                }
            else if(frame == 4){
                if(aeg % 30 == 0){
                    beforeframe = frame;
                    frame -= 1;
                    }
                }
        }
        
        aeg += 1;
        if(aeg == 61)
            aeg = 0;
            
        return frame;
    }
 

This is my frame selecter code, but it doesent seem to work right. This control eye blinking. speed is easy to adjust just change the values of time and its ok. But the problem is frame selection. It seem to jump over some frames and leave other frames out. and it also dissapears randomly. what could be the problem?


Draw sprite in object class and return to main class

25 April 2013 - 12:19 PM

Im trying to make a simple game. I have the basic understanding of spreadsheet and the coding itself, but im havign problems now and then.
Can i place the drawImage function in my object class so that i can return it anywhere i want. example. Boar.java has a line

if(boss.isVisible())
   boss.drawBoss();

adn the Boss.java has this
 

public Image drawBoss(){
     Graphics g
     Graphics2D g2d = (Graphics2D)g;
     return g2d.drawImage(.....)
}

 

So how to i make this work??

 


PARTNERS