Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (808)
Games in Android Showcase (239)
games submitted by our members
Games in WIP (872)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: 1 [2] 3 4 5
31  Game Development / Newbie & Debugging Questions / Override what? on: 2012-02-17 03:17:10
In my NPC interface I have:
1  
public void move(int x, int y);


My Character class has this:
1  
public class Character extends Component implements NPC


When I have Eclipse automatically add the unimplemented methods, it doesn't add move(), so when I manually create it having @override, it tells me that I'm overriding the move method of Component.  Is there a way to tell it that I'm overriding the NPC interface method and not the Component class?
32  Game Development / Game Play & Game Design / Re: your turn / my turn logic on: 2012-02-07 18:10:10
My way doesn't change listeners.  The main class handles the listening and forwards the events to the current state.  I just thought it was easier this way.
33  Game Development / Game Play & Game Design / Re: your turn / my turn logic on: 2012-02-07 05:15:54
My solution to listeners was to have the main class handle the actual "listening" and then sending the event to the current State.
My State interface:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
public interface State {
      public void next(Graphics g);   //I'm not allowed to call it Update for some reason  :(
      public void mouseClicked(MouseEvent evt);
      public void mouseEntered(MouseEvent evt);
      public void mouseExited(MouseEvent evt);
      public void mousePressed(MouseEvent evt);
      public void mouseReleased(MouseEvent evt);
      public void mouseDragged(MouseEvent evt);
      public void mouseWheelMoved(MouseWheelEvent evt);
      public void mouseMoved(MouseEvent evt);
      public void keyPressed(KeyEvent evt);
      public void keyReleased(KeyEvent evt);
      public void keyTyped(KeyEvent evt);
     
   }

Then my main class has the listeners and simply forwards the event; my keyPressed event in the main Class:
1  
2  
3  
4  
@Override
   public void keyPressed(KeyEvent evt) {
      state.keyPressed(evt);
   }


You can set state to be any class implementing State.  I am passing 'this' to my classes when creating them, and they set it to an internal variable of the main class called 'me'  Then I can change state by doing a me.state = ...  I do not have my main class implement State, the examples probably do so to make sure you have all the procedures necessary.  Or maybe there's another reason, I dunno.
34  Game Development / Newbie & Debugging Questions / Re: Problems with loading images on: 2012-02-07 04:56:26
@ReBirth & Giovanni, perhaps your problem is you aren't refreshing when adding new images to the source?  After I save an image, either new or edited, to my /src/res/ directory... In order to see the changes I have to right click on my project name(listing on the left side of eclipse window) and choose Refresh.  This will copy everything in the src/* to the bin/*.  Your resources should then be available to the build, and when exported the last Refresh will be included in the jar file.
35  Game Development / Newbie & Debugging Questions / Re: Point me to some helpful newb Tutorial plz on: 2012-02-02 03:56:02
And this: http://math.hws.edu/javanotes/
36  Game Development / Newbie & Debugging Questions / Re: A simple basic question: calling a method return... on: 2012-01-31 03:54:29
Change the line that reads:
1  
String message;

to:
1  
String message = "";


also, ra4king beat me to it, because I didn't realize I wasn't logged in, and couldn't remember my password Sad
37  Game Development / Newbie & Debugging Questions / Re: Game Interactables on: 2012-01-29 23:54:56
Do you have a class for tiles and interactables?  I'd give the tile class a variable assigned to the interactable class, then if you try to interact, check to see if that tile's interactable is null, if not proceed. 
38  Game Development / Newbie & Debugging Questions / Re: JPanel Problem =/ Question(My Code Provided) on: 2012-01-29 23:48:02
I've tried this too.  Using regular awt buttons and stuff works, but I can't get it to work with JPanel and Jbuttons.  I came across this link when searching for an answer:

http://stackoverflow.com/questions/5636170/jbutton-is-drawing-behind-an-image
39  Game Development / Newbie & Debugging Questions / Re: JPanel Problem =/ Question(My Code Provided) on: 2012-01-29 23:12:39
Change:
1  
g.dispose();

to:
1  
g2d.dispose();


...maybe?  And do you have @Override above your paint mentod?
40  Game Development / Newbie & Debugging Questions / Re: putting applets in a post on: 2012-01-20 03:09:11
I tried too, it didnt' work

Quote
[applet archive=http://www.thenewidea.biz/gbeebe/grndzero.jar class=grndzero.class width=600 height=400]
41  Game Development / Game Play & Game Design / Re: Game Graphics Style Opinions on: 2012-01-17 15:56:18
I think I liked the 1st sketch better, I don't know if it was the view point, or the fact that you only needed to see the north wall, or maybe it's the thin border around the walls.  Also, if there's a rug in the room, you know there's a key under it   Wink 
42  Game Development / Newbie & Debugging Questions / Re: having trouble with fulscreen! on: 2012-01-12 05:49:47
implement ComponentListener, then:
1  
2  
3  
4  
5  
public void componentResized(ComponentEvent evt) {
      // Reset the game dimensions:
      screenWidth = getSize().width;
      screenHeight = getSize().height;
}


Then reszize your JFrame?
43  Game Development / Newbie & Debugging Questions / Re: Dividing my game into classes? on: 2012-01-12 05:05:06
@ra4king, this looks like what I'm looking for, but now I'm even more confused. 
What I think I understand now:
-The idea behind this is I can have my main class create a couple of states, and depending on what the current state in use is, I can call the appropriate states identical method.   My update() method of the main class can call the update() method of the menu class. 
-I only need to have listeners in my main class then and then have corresponding methods in the states.

I'm not 100% sure why I need to use interfaces,  I assume it's for simplicity.  And how would I share variables between these?

44  Game Development / Newbie & Debugging Questions / Dividing my game into classes? on: 2012-01-11 05:18:11
So, my game is starting to get a bit cluttered and I've been thinking about trying to divide parts into separate classes, and I must admit that my inexperience with Java is catching up to me.  I have Character and Projectile classes, but what I would like to have is an InGame class, Menu class, and LevelLoader class which are currently methods inside the main class.  The problems that I don't already know the answers to:

-The levelLoader methods create images which are declared in the main declaration section, and are used in the main loop run() for inGame purposes.  Can Images/any variable or object be passed as arguments as not read only, or can I access the parrent class's global variables some how?

-The Menu method shares the same keyboard and mouse listeners as the in game code.  I'm assuming I can have a Menu class with mouse and keyboard listeners, I don't know if I need to remove the in game listeners before adding listeners in the Menu class, or the proper way to do this.  Also, the update() and paint() methods check to see what to draw (game/menu) and does so accordingly.  If I want the them to have separate drawing methods how would I do that?

Thanks in advance.

45  Game Development / Newbie & Debugging Questions / Re: Creating many entities of an enemy or object from one method on: 2011-12-31 03:16:49
http://math.hws.edu/javanotes/ a good free book online.
46  Game Development / Newbie & Debugging Questions / Re: Check for applet keyboard focus? on: 2011-12-29 02:27:32
Sweet, if(this.hasFocus())  works perfectly for what I need.  You're all right.  I don't care what everyone else says about you.   Wink
47  Game Development / Newbie & Debugging Questions / Check for applet keyboard focus? on: 2011-12-29 01:23:11
Is there a way for an applet to determine if it's got the keyboard focus or not?  I would like to display a "game paused, click to resume" message to the user when it looses focus.  I've tried to implement FocusListener, but focusGained() and focusLost() don't seem to do anything.  Anyone know of a way to check for focus in an applet?
48  Game Development / Newbie & Debugging Questions / Re: Problem reading keys on: 2011-12-27 05:07:01
If you were doing it the way we talked about in another post of yours, with a boolean value like keyEnter:  You can make it a non-repeating key.  In the part of the program where you check to see if keyEnter is true (set by keyPressed and keyReleased), if it is true then immediately set it to false and carry on, then the next time you check to see if it is true it won't be unless you have released and pressed it again.

... Also I wouldn't use multiple key listeners.  Just have one that sets the boolean variable representing that key and use your main/menu loops to work with them.
49  Game Development / Newbie & Debugging Questions / Re: Using threads to wake me up - Check my code please on: 2011-12-23 03:12:52
...so, did you get up on time?
50  Discussions / General Discussions / Re: Canonical to remove Oracle's Sun Java from User's Systems on: 2011-12-23 02:29:52
@nsigma, sorry after looking in my dowloads folder, it's a .bin (self extracting) file.  It's been a while, and now that I think about it, I did have to link to the .so file in the Chrome plugin directory.  But it wasn't anything too tedious = probably why I was thinking now that it was a .deb then... My apologies.
51  Discussions / General Discussions / Re: Canonical to remove Oracle's Sun Java from User's Systems on: 2011-12-22 03:59:52
Apples and Oranges my friend.
52  Game Development / Newbie & Debugging Questions / Re: Pressing vs. holding down a button on: 2011-12-22 03:44:14
...and I modified it, adding code to help what we both are trying to say  Smiley
53  Game Development / Newbie & Debugging Questions / Re: Pressing vs. holding down a button on: 2011-12-22 03:37:27
In the keyPressed section set a boolean variable that represents your key to true.  and do the opposite in the keyReleased section.  Then in your main loop check to see if the key is true or false and do accordingly.

For example:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
//In your variable declaration section
boolean keyA = false;
///etc...

//In your keyPressed event
if (key == KeyEvent.VK_A)
      {
         keyA = true;
      }

//In your keyReleased event
if (key == KeyEvent.VK_A)
{
    keyA = false;
}

//Somewhere in your main loop
if (keyA)
{
    if ((key2 != 2) && (key2 != 3) && (key2 != 4))
         {
            if (imgSwitchHoriz) player = leftRunning.getImage();
            if (!imgSwitchHoriz) player = leftStill.getImage();
            key2 = 1;
            dx = negChange;
            if (imgSwitchHoriz) imgSwitchHoriz = false;
            else if (!imgSwitchHoriz) imgSwitchHoriz = true;
         }
}
54  Discussions / General Discussions / Re: Canonical to remove Oracle's Sun Java from User's Systems on: 2011-12-22 02:44:46
I downloaded the .deb package straight from the java website and installed it that way.  OpenJDK blows for numerous reason, but the #1 reason why I got rid of it was because of the keyPressed and keyReleased glitch.  If Canonical removed Sun Java from my machine, I'll be pissed, but then again I can just reinstall it... Unless they block it.  Then I'll switch to Mint or something.
55  Games Center / WIP games, tools & toy projects / GroundZero (work in progress) on: 2011-12-21 04:34:48

It's going to be a Worms/Scorched Earth clone, but for now it's just a toy.

I'm posting to it to find out if anyone (read "any machine") has a problem loading it, and to make sure the controls work, especially the Right Click (I hear that's a bit tricky on Macs).  

http://thenewidea.biz/gbeebe/

PS: I'm aware that it's quite buggy, Currently trying to figure out why the sprites jitter every once in a while.
56  Game Development / Newbie & Debugging Questions / Re: Applet takes long to exit on: 2011-12-16 04:20:08
I agree with ra4king.  As long as it IS shutting down, why worry about the few seconds it takes to do so.  Don't worry about optimizing everything until the game is playable start to finish.  Then make it better... or release it and carry on to the next game, knowing what to do and what not to do... Otherwise you'll end up like me - It'll probably be a year before my game is done, I can only hope I still feel like writing this game in 6 months from now.
57  Game Development / Newbie & Debugging Questions / Re: How to create movement with acceleration/force? 2D platformer on: 2011-12-15 02:41:47
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
public void move()
   {
    speed = speed + dx;

      x += speed;
      y += dy;
     
      if(y > 760 || y < 0)
      {
         dead = true;
         x = startX;
         y = startY;
      }
}


You may want to cap the min and max of speed, and you may find that this acceleration is too fast, if so change speed, and x to a double and:
1  
2  
speed = dx * 0.001;
x = x + speed)


You can change 0.001 to your desired rate of acceleration.  Also, for slowing down, if dx = 0 figure out if speed is negative or positive and head towards zero.
58  Game Development / Newbie & Debugging Questions / Re: Text Adventure loosely based on "Oblivion", help with bug on: 2011-12-13 02:56:16
Are you sure the game is in the right spot when you type "e", it may mean "exit" which is calling SaL.Save() which has running = false;
59  Game Development / Newbie & Debugging Questions / Re: Text Adventure loosely based on "Oblivion", help with bug on: 2011-12-13 02:36:49
Is this when the user types "exit" in the equip menu?  Or when Sal.Save() is called?  I would put a message saying "saved" in there so you can see if that point was reached.
60  Game Development / Newbie & Debugging Questions / Re: Reading a String on: 2011-12-12 01:35:39
1  
if (input.toLowerCase().startsWith("a"))
?
Pages: 1 [2] 3 4 5
 
Riven (845 views)
2019-09-04 15:33:17

hadezbladez (5786 views)
2018-11-16 13:46:03

hadezbladez (2602 views)
2018-11-16 13:41:33

hadezbladez (6202 views)
2018-11-16 13:35:35

hadezbladez (1498 views)
2018-11-16 13:32:03

EgonOlsen (4732 views)
2018-06-10 19:43:48

EgonOlsen (5789 views)
2018-06-10 19:43:44

EgonOlsen (3274 views)
2018-06-10 19:43:20

DesertCoockie (4174 views)
2018-05-13 18:23:11

nelsongames (5500 views)
2018-04-24 18:15:36
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!