Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (117)
games submitted by our members
Games in WIP (564)
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
1  Discussions / Miscellaneous Topics / Re: How often do you code on: 2014-09-21 08:49:14
around 10 hours on a normal day, but that's just because I'm a software developer. I spend around 3 hours every day on my own projects.
2  Discussions / Miscellaneous Topics / Re: Whays the story behind your name on: 2014-09-21 08:42:18
I needed a name for my druid on world of warcraft, so I opened notepad, and then hit my keyboard a few times. I took out some random letters, and ended up with Yemti, but decided to change it to Yemto since that sounded better.
3  Discussions / Miscellaneous Topics / Re: What other programming languages do you use & why? on: 2014-09-21 05:46:23
I started a guild on world of warcraft, which got around 60 members, some people wanted a homepage, and I didn't want to disappoint. I have kind of a big ego, and didn't want to use a layout/template, because I wanted to be able to say it was my homepage, that I had done it. So I started to learn html and css 2007-01-07 was when I got the first version of the website online.

After that I wanted to learn more. Which got me to start with game maker and begin with php and I loved it. My friend gave me game maker pro to my birthday, and I started to make a multiplayer game since I now could use DLL files, and my friend liked the game, so I kept building on it, until I wanted to move on from game maker. I tried C++ but I never got into it, then I decided to try java which I ended up loving.

Now and then I went back to php, by that time my world of warcraft days was over, but I still wanted to make homepages, so I started to learn MySQL and javascript, and that's is my programming history. Recently to learn how to do ajax calls, and is now using PDO to access my MySQL databases.
4  Discussions / Miscellaneous Topics / Re: Inventory system in MySQL on: 2014-09-15 18:22:52
No, since this isn't a java game, It's a turn based RPG web game, coded mainly with php and javascript. I use PDO to connect to the database, and of course html, html5 and css.

I don't see how else I would make an item without item_stack without copying the whole item, which would be a waste of space, and would make the code much messier. How would I make it possible for a character to split stacks, or even have stacks in the first place?

I'm not sure about your idea with the slots_<number> in the inventory table, since I'm going to have furniture with a lot more inventory space, so I would need slot_1 to slot_50, which is way too much in my opinion. So I think it's better to have a size number instead.

What you said about the inventory table made me think, if I made it something like; inventory_id, item_id, amount_id, slot and then I stored the last created id inside whatever have the inventory. That way I could move around items much easier. Sure the item have no idea where they are, but the right bag/furniture/character/location would have a much easier time to locate them, and maybe I could have a inventory_layout table to have specific layouts and sizes.
5  Discussions / Miscellaneous Topics / Re: Inventory system in MySQL on: 2014-09-14 17:01:28
Could you explain what the point of this table is? What is its average use case.

It is to create items. The table "item" contains most of the data of the items, like name, tooltip, icon, witch inventory it have. While this table "item_stack" is used to keep track where the item is, who owns it, and the amount/uses of the item.
6  Discussions / Miscellaneous Topics / Inventory system in MySQL on: 2014-09-14 16:04:19
This is for a game I'm working on, but it have nothing to do with java, so I need to post it here. So far I have set up the database like this

This is the character table, inventory_id is meant to get the slots where the player can put the equipment
Quote
account_id | name   | race            | health | mana | exp | created                      | sex | character_id | world_id | inventory_id
2              | Yemto  | Humanoid    | 100    | 100    | 0    | 2014-06-10 20:44:28  | 1     | 7                | 0           | 1
2              | Fire      | Spirit           | 100    | 100    | 0    | 2014-06-11 03:00:43  | 0     | 7                | 0           | 2
2              | Test     | undead        | 100    | 100    | 0    | 2014-06-18 10:44:43  | 1     | 7                | 0           | 3

This is what the item table looks like, it's meant to hold most of the date of an item   
Quote
item_id | name     | info     | icon   | stack_size | untradable | inventory_id
1          | bag       | NULL    | NULL  | 10           | 0               | 2
2          | cheese   | NULL   | NULL  | 100          | 0               | NULL
5          | tea        | NULL   | NULL  | 100          | 0               | NULL
6          | Big bag  | NULL   | NULL  | 100          | 0               | NULL

The inventory table is so far only used to set how many slots and what type of slots a inventory have.
Quote
inventory_id | normal_slots | weapon_slots | bag_slots
1                 | 0                  | 2                  | 1
2                 | 6                  | 0                  | 0

This is the item_stack table, when someone buys an item an entry in this table is created to create the item.
Quote
item_stack_id | item_id | amount | recursive_id | slot | owner | recursive_table
1                   | 3          | 1          | 5                 | 0    | 7        | character
2                   | 5          | 2          | 1                 | 0    | 7        | item_stack
3                   | 6          | 5          | 1                 | 1    | 7        | item_stack
4                   | 5          | 6          | 1                 | 2    | 7        | item_stack
5                   | 3          | 1          | 7                 | 0    | NULL   | city

To get something usable from item and item_stack I'm using this
1  
2  
3  
4  
$item = $conn -> prepare("SELECT * FROM `item_stack` LEFT JOIN `item` USING (`item_id`) WHERE `item_stack_id`=:id");
$item -> bindParam(":id",$this->id);
$item -> execute();
$this -> item = $item -> fetch();


But this is where I encountered a problem. recursive_id and recursive_table in the item_stack table is to keep track of who holds the item, which works. But if I want to back track to see if the inventory size is valid, I can't. Lets say a player find a way to put something in slot 8 in a bag, and as you probably can see, the bag don't have that many slots. I had the idea of using the recursive_table and recursive_id to see which inventory the item have.

This is the code I began coding, until I realized that it doesn't work.
1  
2  
$inventory = $conn -> prepare("SELECT `inventory_id` FROM `{$recursive_table}` WHERE `{$recursive_table}_id`=:rid");
$inventory -> bindParam(":rid",$recursive_id);


The code works for characters, but not for item_stack since that will just get another entry to another item_stack which don't contain inventory_id. I thought of doing something like this.

1  
2  
3  
4  
5  
6  
7  
if($recursive_table == "item_stack"){
$recursive_table = "item";
$recursive_id = $stack["item_id"];
}

$inventory = $conn -> prepare("SELECT `inventory_id` FROM `{$recursive_table}` WHERE `{$recursive_table}_id`=:rid");
$inventory -> bindParam(":rid",$recursive_id);


But I don't know, it don't seem to be the best say to me, so I was wondering is anyone here had a better solution.

This is a good example of what kind of inventory system I'm going for
http://mmohuts.com/wp-content/gallery/runes-of-magic/runes-of-magic-inventory.jpg?bb7a3b
7  Discussions / Miscellaneous Topics / Re: Problem with patterns in java on: 2014-09-12 03:17:45
Thanks so much, It works flawlessly. I had no idea ? could be used with groups.
8  Discussions / Miscellaneous Topics / Problem with patterns in java on: 2014-09-09 10:41:03
This is not related to any game I'm developing, so that's why I don't post it here.

Here is my pattern code
1  
Matcher m = Pattern.compile("\\[((.*?),|)(\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2})(,(.*?)|)\\]").matcher(text);


The problem I have with it that I want to be able to write things like this
[text,2014-09-09 19:00:00]
[text,2014-09-09 19:00:00,text]
[2014-09-09 19:00:00,text]
[2014-09-09 19:00:00]

What I want to happen is.
((.*?),|) = Return any text without the "," or null
(,(.*?)|) = Return any text without the "," or null
(\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}) = Returns time and date in, yyyy-mm-dd hour:min:sec format

When I test with this [2014-09-09 19:00:00] I get these group
0: [2014-09-09 19:00:00]
1:
2: null
3: 2014-09-09 19:00:00
4:

and I can't understand why group 4 isn't null like group 2
9  Game Development / Newbie & Debugging Questions / Re: KeyEventDispatcher stops working on: 2014-09-05 13:51:38
You said that your Listener no longer listen to your keyboard, by function
1  
removeKeyEventDispatcher()
you remove the listner, so in your main function, maybe in constructor, you should have
1  
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(scannerEngine.getKeyEventDispatcher());
, and maybe wherever you want to stop the listener, you will use what you write,
1  
KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventDispatcher(scannerEngine.getKeyEventDispatcher());


I can't believe that I missed that one "addKeyEventDispatcher" was a "removeKeyEventDispatcher"... Now I just feel dumb.
10  Game Development / Newbie & Debugging Questions / Re: KeyEventDispatcher stops working on: 2014-09-05 13:17:39
I used to have a Keyboard class which implements KeyListener, like in example below:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
public class Keyboard implements KeyListener{

   private boolean[] keys = new boolean[256];
   public boolean up, down, left, right, esc;
   
   public void update(){
      up = keys[KeyEvent.VK_UP] || keys[KeyEvent.VK_W];
      down = keys[KeyEvent.VK_DOWN] || keys[KeyEvent.VK_S];
      left = keys[KeyEvent.VK_LEFT] || keys[KeyEvent.VK_A];
      right = keys[KeyEvent.VK_RIGHT] || keys[KeyEvent.VK_D];
      esc = keys[KeyEvent.VK_ESCAPE];
   }
   
   public void keyPressed(KeyEvent e) {
      keys[e.getKeyCode()] = true;
   }

   public void keyReleased(KeyEvent e) {  
      keys[e.getKeyCode()] = false;
   }

   public void keyTyped(KeyEvent e) {
   }
}


And in the Main class I had an istance for Keyboard, attributed as parameter for function "addKeyListener(MY KEYBOARD ISTANCE)". I hope that helps you.

Sadly that doesn't work for me.

Here is my code I made, it's my own little Listener, and it works fine for a while, and then it suddenly stops working.
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  
30  
31  
32  
33  
34  
private final KeyEventDispatcher toScanner = new KeyEventDispatcher(){
        @Override
        public boolean dispatchKeyEvent(KeyEvent event){
            if(event.getID() != KeyEvent.KEY_RELEASED)
                return false;
           
            if(event.getKeyCode() == 10){
                if(System.currentTimeMillis() - scanTime < 1000){
                    for(ScanListener l : listeners)
                        l.onScanComplete(createScanEvent(null));
                    scan = null;
                }
               
                event.consume();
                return true;
            }
           
            if(scan == null){
                scan = new StringBuilder();
                scanTime = System.currentTimeMillis();
                for(ScanListener l : listeners)
                    l.onScanBeing(createScanEvent(event.getKeyChar()));
            }
           
            if(scan != null){
                for(ScanListener l : listeners)
                    l.onScanInProgress(createScanEvent(event.getKeyChar()));
                scan.append(event.getKeyChar());
            }
           
            event.consume();
            return false;
        }
    };


The scannerEngine.getKeyEventDispatcher returns toScanner.
1  
KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventDispatcher(scannerEngine.getKeyEventDispatcher());
11  Game Development / Newbie & Debugging Questions / KeyEventDispatcher stops working on: 2014-09-05 13:00:21
So I have been working on a program in java for a while now, but I have yet to solve a annoying problem, the JFrame seems to stop listen to the keyboard, I have tried with KeyListener and KeyEventDispatcher. But not matter which one I use, it still happens. I need to program to listen to the keyboard without fail, no matter where the focus are, well it's okay if it doesn't when the program is minimized.
12  Game Development / Newbie & Debugging Questions / Re: Sending data with ServerSocket on: 2014-07-31 05:36:59
it seems your client (or server) are shutting down immediately, but with flush it should as good as with close.

I don't understand, I have tested with both flush and/or close, but either I get "data 1", or I get nothing.
13  Game Development / Newbie & Debugging Questions / Re: Sending data with ServerSocket on: 2014-07-31 04:55:46
Well, you dont need to close it?!

1  
2  
3  
OutputStream out = socket.getOutputStream();
            out.write(message.getBytes());
            out.close();


Just open the outputStream after the initialisation of the connection and keep it open. If your Client got no data, try to flush() after writing.

Sadly that doesn't work, here is the results.

with close()
1  
2  
3  
4  
5  
6  
7  
8  
9  
Server: Running
Client: attempt to connect
Client: Data 1
java.net.SocketException: Socket is closed
   at java.net.Socket.getOutputStream(Socket.java:943)
   at Pokemon.Server.Server.sendMessage(Server.java:60)
   at Pokemon.Server.Server.sendMessage(Server.java:70)
   at Pokemon.Game.Test.main(Test.java:26)
BUILD SUCCESSFUL (total time: 1 second)


with Flush()
1  
2  
3  
Server: Running
Client: attempt to connect
BUILD SUCCESSFUL (total time: 1 second)


As you can see, only when I close do the client receive the message, and  it only receive the first one.
14  Game Development / Newbie & Debugging Questions / Sending data with ServerSocket on: 2014-07-31 04:42:46
So I have began with doing a turn based rpg game, which going to have multiplayer, but I have run into a problem. I don't know how to send data to a socket without closing it, sure I could make the clients re-connect to the ServerSocket to receive new data, but that seems wrong to me, or is it?

Some code I tested with
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
public void sendMessage(Socket socket, String message){
        try{
            OutputStream out = socket.getOutputStream();
            out.write(message.getBytes());
            out.close();
        }catch(IOException e){
            e.printStackTrace();
        }
    }
   
    public void sendMessage(String message){
        for(Socket s : players)
            sendMessage(s, message);
    }


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
public class Test {    
    public static void main(String[] args) throws Exception{
        Server server =  new Server(1233);;
        Client client = new Client("127.0.0.1", 1233);
       
        server.sendMessage("Data 1");
        server.sendMessage("Data 2");
       
        Thread.sleep(1000);
        System.exit(0);
    }
}
15  Discussions / Miscellaneous Topics / Re: Can I use the word "perk" in my game? on: 2014-06-01 21:32:02
*facepalm* I think I have been trying to find an unnecessary fancy word
16  Discussions / Miscellaneous Topics / Can I use the word "perk" in my game? on: 2014-06-01 21:07:42
I'm making a game where at the start the player have taken a potion which is still in the experimental stage, which is a part of the level up mechanic. When a player level up they can spend one point in the potion's tree to unlock a side effect. I have been thinking of calling them perks, but the thing is not everything in that tree is good, so I'm not sure perk suits those negative effects.
17  Discussions / Miscellaneous Topics / Re: [html/php] Create anything from the a character creation page on: 2014-05-28 11:45:30
Sorry Sad
18  Discussions / Miscellaneous Topics / [html/php] Create anything from the a character creation page on: 2014-05-28 11:36:36
I'm posting this here since it's not about java. I'm currently working on remaking a website I made 5 years ago, while I had a backup on the site I hadn't a backup on the database, so I have lost everything. Anyway, what I wanted for the game is that the player could be literally anything. Since it was text based I didn't need to worry about sprites or animations.

I turned off the online check for the character creation page so people can access it without needing to create an account. http://213.65.196.41/Creature_Controller/user/create_charater.php how it works it simple, to create a farity I could take; Humanoid, Tiny, then magic and flying, or if I want to be a dragon I could take; Beast, big, then flying, tough, and strong.

The problem I have is comming up with perks, and more things that a character could be classified as, and was hoping people could help me.
19  Discussions / General Discussions / Re: [Non-game] Some questions about making a program on: 2014-05-19 20:56:00
Thanks, that was the answer it was looking for.
20  Discussions / General Discussions / Re: [Non-game] Some questions about making a program on: 2014-05-19 20:50:37
So I just need to use System.out.print to pass the string into a variable in php?
21  Discussions / General Discussions / Re: [Non-game] Some questions about making a program on: 2014-05-19 20:08:05
It took some time, but I have now made the program use TimerTask and Timer when it needs to execute something with a delay, and it's regular check up with the website. I still uses repaint in the paintComponent, I could possibly move it to a TimerTask and use "scheduleAtFixedRate" every 1000 ms (the window have a clock that need to update each second.)

But I have encountered one other problem, the java program encrypts some data before it send it to the server. But now the website need to do that too. So I wonder can I pass some arguments into a jar, and get a string out directly? or do I need to make the jar save the result into a file which it put into a temp folder, which the website can read?
22  Discussions / General Discussions / Re: [Non-game] Some questions about making a program on: 2014-05-18 22:26:47
From what I know repaint just schedules the next time the program need to render again, and without repaint everything just render once. But I will take your advice about sleep, since that  was what I was thinking of doing, just wanted to check if it was the right way.
23  Discussions / General Discussions / [Non-game] Some questions about making a program on: 2014-05-18 22:12:39
I have been tasked to make a check in/out program for my job. While I have worked with games before, I have never really done just a simple program, and I'm sure I have made a couple of mistakes.

First of all, I believe what I'm using is called passive rendering. The program doesn't use any keyboard, or mouse input. So I decided to make it look nice with a full screen window, that have a background and a good looking list of all the employees that have checked in. (We use a card scanner to check in/out)

1  
2  
3  
4  
5  
6  
7  
@Override
    public void paintComponent(Graphics g){
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D)g;
        //Rendering code
       repaint();
    }


But then I come to the thing I'm most questionable about, I have used a game loop to check in with a "in house" website now and then, to collect information. I have been thinking of adding a sleep, yield, or another kind of timer function.

1  
2  
3  
4  
5  
6  
7  
8  
9  
public void processing(){
        while(isRunning){
            long now = System.currentTimeMillis();
            if(now-lastHttpCheck > getSoftwareRefreshRate()){
                lastHttpCheck = now;
                //Resive information from a in house apache server
           }
        }
    }
24  Java Game APIs & Engines / Engines, Libraries and Tools / Re: rendering problem on: 2014-05-08 23:54:13
Since no one have protested against this, I take this is an okay idea. I really did one change, I made "LevelComponent" into an interface.

1  
2  
3  
4  
public interface RenderComponent {
    public void render(Graphics2D g2, int offsetX, int offsetY, int offsetZ);
    public int getRenderPriority();
}


This is what the rendering method ended up looking like.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
public void render(Graphics2D g2, int offsetX, int offsetY, int offsetZ){
        //Sort everything that is going to get rendered
       render.sort((w1, w2) -> {
            int renderScore1 = w1.get() != null ? ((RenderComponent)w1.get()).getRenderPriority() : -1;
            int renderScore2 = w2.get() != null ? ((RenderComponent)w2.get()).getRenderPriority() : -1;
            return renderScore2 - renderScore1;
        });
       
        //Check everything that's going to get rendered, and remove garbage data.
       for(int i=0; i<render.size(); i++){
            RenderComponent r = render.get(i).get();
            if(r == null){
                render.remove(i); i--;
                continue;
            }
           
            //Render
           r.render(g2, offsetX, offsetY, offsetZ);
        }
    }
25  Java Game APIs & Engines / Engines, Libraries and Tools / Re: rendering problem on: 2014-05-08 20:32:56
Because the Tiles and Entities will end up overlapping each other. Like if I render the entities first, and then the tiles all entities will be under the level, and if I do it in the reverse order all entities wouldn't be able to be behind terrain.

I use WeakReferences so I don't need to check in the rendering if the tile or entity exists, because then the garbage collector will take care of that.
26  Java Game APIs & Engines / Engines, Libraries and Tools / rendering problem on: 2014-05-08 20:11:10
So I'm making a 2D sprite based isometric game in java without any libraries. It go well so far but I have encountered a problem with my rendering. My levels consist of a 3D array of a abstract class called Tile, but now I want to be able to render entities on the map too. So what would be a good way of doing that? Since the Entity class is in a ArrayList i can't simply loop through it. I have been thinking of having an ArrayList that consists of WeakReferences to a class called LevelComponent that only contains x, y, z, and sprite. While the update method loops through the Tile, and Entity class respectively

Here is some made up code on how I thinking of doing it.
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  
30  
31  
32  
33  
34  
public class Map{
   List<WeakReference<Entity>> render = new ArrayList<>();

   public void update(float alpha){
      for(int i=0; i<entities.size(); i++){
         Entity e = entities.get(i);
         if(e.isDead()){
            entities.remove(i); i--;
            continue;
         }
         
         e.update(alpha);
      }
     
      for(int x=0; x<SIZE_WIDTH; x++)
         for(int y=0; y<SIZE_HEIGHT; y++)
            for(int z=0; z<SIZE_TOP; z++)
               if(t != null)
                  t.update(alpha);
                 
   }

   public void render(Graphics2D g2, int offetX, int offsetY){
      for(int i=0; i<levelComp.size(); i++){
         LevelComponent l = levelComp.get(i).get();
         if(l == null){
            levelComp.remove(i); i--;
            continue;
         }
         
         l.render(g2, offetX, offetY);
      }
   }
}


Is there a better way I don't see?
27  Game Development / Newbie & Debugging Questions / Re: Problem with IllegalAccessException on: 2014-04-29 23:57:57
I finally manage to solve the issue, I just added m.setAccessible(true); to the function

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
protected void runMethod(String method, Class argumentClass, Object... object){
        if(!isEnabled())
            return;
        try{
            for(VillageListener l : listeners){
                if(l == null)
                    continue;
                Method m = argumentClass != null ? l.getClass().getMethod(method, argumentClass) : l.getClass().getMethod(method);
                m.setAccessible(true);
                if(m.isAnnotationPresent(VillageEvent.class))
                    m.invoke(l, object);
            }
        }catch(NoSuchMethodException | NoClassDefFoundError e){
            //These aren't important as long as they don't cause significant performance issues.
       }catch(SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e){
            e.printStackTrace();
            enable = false;
        }
    }
28  Game Development / Newbie & Debugging Questions / Problem with IllegalAccessException on: 2014-04-29 17:57:13
So I'm working on making a game with plugin support, and today I encountered a problem. The game uses two .jar file, VillagePlus.jar which is the game it self, while VillageContent.jar is the plugin I'm testing on.

This is the message I get when I try to run one of my test plugins
Quote
java.lang.IllegalAccessException: Class Village.Plugin can not access a member of class villagecontent.VillageContent$1 with modifiers "public"
   at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:101)
   at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:295)
   at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:287)
   at java.lang.reflect.Method.invoke(Method.java:476)
   at Village.Plugin.runMethod(Plugin.java:150)
   at Village.Screen.lambda$render$5(Screen.java:118)
   at Village.Screen$$Lambda$12/286652023.accept(Unknown Source)
   at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1359)
   at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
   at Village.Screen.render(Screen.java:118)
   at Yemto.screen.ScreenFragment.render(ScreenFragment.java:123)
   at Village.Game.render(Game.java:190)
   at Village.Game.run(Game.java:160)
   at java.lang.Thread.run(Thread.java:745)

Here is the plugin
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  
package villagecontent;

import Village.Game;
import Village.Plugins.*;
import Village.Plugins.TriggerEvent.RenderEvent;
import java.awt.*;

public class VillageContent implements VillagePlugin, VillageListener {
   
    @Override
    public void onEnable(){
       Game.registerListener(new VillageListener(){
           @VillageEvent
            public void onRenderEvent(RenderEvent event){
                Graphics2D g2 = event.getGraphics2D();
                g2.setColor(Color.WHITE);
                g2.drawString("Testing mod", 700, 700);
            }
       }, this);
    }

    @Override
    public void onDisable() {
       
    }
}


This is just a simple method to save the Listener into a HashSet inside the plugin object.
1  
2  
3  
public static void registerListener(VillageListener listener, VillagePlugin plugin){
        Game.plugins.stream().filter(p -> p.getMain().equals(plugin)).forEach(p -> p.addListener(listener));
    }


My run method method
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
protected void runMethod(String method, Class argumentClass, Object... object){
        if(!isEnabled())
            return;
        try{
            for(VillageListener l : listeners){
                if(l == null)
                    continue;
                Method m = argumentClass != null ? l.getClass().getMethod(method, argumentClass) : l.getClass().getMethod(method);
                if(m.isAnnotationPresent(VillageEvent.class)){
                    m.invoke(l, object);
                }
            }
        }catch(NoSuchMethodException | NoClassDefFoundError e){
            //These aren't important as long as they don't cause significant performance issues.
       }catch(SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e){
            e.printStackTrace();
            enable = false;
        }
    }


I have no real idea what to do, the only thing I can think of is I somehow need to load the villagecontent.VillageContent$1 into the game.
29  Game Development / Newbie & Debugging Questions / Re: Raw material in a game on: 2014-04-23 08:52:52
I'm not looking to make it very easy to mod, I have made plugins with bukkit and plan on going about it the same way, since it makes most sense to me. That is to make a mod/plugin the modder adds the game .jar file into the project and then can use event classes and methods to add, remove, change content in the game. Then after compile the mod it's just to put it in the games plugin/mod folder.
30  Game Development / Newbie & Debugging Questions / Re: Raw material in a game on: 2014-04-22 22:31:58
You have the right idea in that most everything is specified as data, although your material class should not be abstract. How you structure it depends on how materials are used in your game. For instance if you have a set of materials that can be used to build walls and a set of precious metal materials (gold, gems, etc) that are defined by their value. In that case you may have two classes, BuildableMaterial and ValuableMaterial.

So far I just focus on the material that's is used to craft walls and items. My idea with abstract was to use something like new Wood() which extends the material class, but I should just use new Material("Wood",Texture.get("wood.png")); instead?

Also so far I use the name of the material to get it, like Material.get("wood"); and if wood don't exists it just return null.
Pages: [1] 2 3 4
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Grunnt (21 views)
2014-09-23 14:38:19

radar3301 (14 views)
2014-09-21 23:33:17

BurntPizza (31 views)
2014-09-21 02:42:18

BurntPizza (22 views)
2014-09-21 01:30:30

moogie (20 views)
2014-09-21 00:26:15

UprightPath (29 views)
2014-09-20 20:14:06

BurntPizza (33 views)
2014-09-19 03:14:18

Dwinin (48 views)
2014-09-12 09:08:26

Norakomi (75 views)
2014-09-10 13:57:51

TehJavaDev (108 views)
2014-09-10 06:39:09
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59: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!