Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (541)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 2 [3] 4 5 ... 10
 21 
 on: 2014-12-27 03:02:40 
Started by The Lion King - Last post by The Lion King
The shot looks really nice, the trail looks a bit funny, there are too many particles. I think you should thin down the amount, and possibly putting one on either side so it looks like it is coming from the treads.

 22 
 on: 2014-12-27 02:42:37 
Started by TheDudeFromCI - Last post by BurntPizza
How is it better than DataOutputStream/DataInputStream?
EDIT: also Files etc.

 23 
 on: 2014-12-27 02:28:39 
Started by TheDudeFromCI - Last post by TheDudeFromCI
Hey, everyone. As most of you already know, reading and writing to a binary file is important for larger projects. Binary files are smaller, and read and write faster. However, working with lots of byte arrays can be very annoying. So I made several classes that should help you all make this process much, much easier. The three classes are attached in the paste bin. Here!


Here's how simple it is to use. Lets say, for example, I have a list of "Person" classes, that I need to store into a file.

1  
2  
3  
4  
5  
6  
public class Person{
    public String name;
    public int age, weight;
    public float height;
    public long phoneNumber;
}


Alright, now let's write this to a file!

1  
2  
3  
4  
5  
6  
7  
ArrayList<Person> people = (Created somewhere else in code); //The arraylist.

BinaryEncoder bin = new BinaryEncoder();
for(Person p : people){
    bin.addShortString(p.name).addInt(p.age, p.weight).addLong(p.phoneNumber).addFloat(p.height);
}
BinaryFileUtils.writeFile(BinaryFileUtils.getFile("Persons.dat", "Data"), bin.get());


And you're done. That's it. No working with complex byte arrays. No measuring, or any math. You're done.
Reading the file is just as easy!

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
ArrayList<Person> people = new ArrayList<>();
BinaryDecoder bin = new BinaryDecoder(BinaryFileUtils.readFile(BinaryFileUtils.getFile("Persons.dat", "Data")));
while(!bin.isDone()){
    Person p = new Person();
    people.add(p);
    p.name=bin.getShortString();
    p.age=bin.getInt();
    p.weight=bin.getInt();
    p.phoneNumber=bin.getLong();
    p.height=bin.getFloat();
}


And it's the exact same list you just wrote into file! Congrats! It's a simple as that. Smiley Enjoy, and tell me when you guys think.

 24 
 on: 2014-12-27 01:48:03 
Started by Sethir - Last post by actual
Another potential option would be to use an enum that extends an interface. This gives you the convenience of a global static field while at the same time allowing you to add multiple instances if the need arises.

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  
35  
36  
37  
public interface ConfigProperties {
   
   void setIntegerProperty(String propertyName);
   void setStringProperty(String propertyName);
   int getIntegerProperty(String propertyName);
   String getStringProperty(String propertyName);
}


public enum GameConfig implements ConfigProperties {

   COLORS,  FONTS;

   private Map<String,Integer> intProperties = new HashMap<String,Integer>();

   private Map<String,String> stringProperties = new HashMap<String,String>();

   // Add an int property
   public addIntValue(String propertyName, int value) {
      intProperties.put(propertyName,value);
   }

   // Add a string property
   public addStringValue(String propertyName,String value) {
      stringProperties.put(propertyName,value);
   }
 
   // Get a string property
   public String getStringProperty(String propertyName) {
      return stringProperties.get(propertyName);
   }

   // Get integer property
   public int getIntProperty(String propertyName) {
      return intProperties.get(propertyName);
   }
}


Then you can access properties like GameConfig.COLORS.getIntProperty("font_highlight") from any class. If you need new categories of parameters it can be as simple as adding a new value to the enum.

 25 
 on: 2014-12-27 01:27:02 
Started by The Lion King - Last post by BurntPizza
Motivation's a bitch as usual, but I did some basic particles; looks alright: (ignoring temp tank texture)

Click to Play


Probably going to need multiple textures and of course some colors to make it look good.
Also some problems creep in when entities are handled by box2d and particles not...

 26 
 on: 2014-12-27 00:51:48 
Started by ABOODYFJ - Last post by ABOODYFJ
Well, I can see why he used them, because they're still about twice as fast when compared to VBOs (I don't know about VAOs, I've never used them because my laptop doesn't support them).

That's true, Plus I really wanted to experiment with the deprecated LWJGL features, I have another project that I'm using VBO's with, VBO's are much better once you learn how to use them.

 27 
 on: 2014-12-27 00:50:23 
Started by Sethir - Last post by KevinWorkman
Good habits like:  Never try to solve potential future problems which cannot exist.

I'm a big fan of the idea that premature optimization is the root of all evil. But this isn't like implementing your own custom parallel sorting algorithm to sort a collection of 10 Strings. This is a pretty low-cost-now solution that *will* save you a ton of headaches in the future.

Different strokes for different folks, and different problems require different solutions, but the OP asked if there was a better practice than misusing statics to give lazy access to class members. There is a better practice: don't misuse the static keyword to give lazy access to class members.

 28 
 on: 2014-12-27 00:48:57 
Started by ABOODYFJ - Last post by ABOODYFJ
Very nice looking mc clone! What algorithm did you use for your terrain generation? also i need some help on mine if you can show me where you learned how to do chunks and generation. I used diamond square for mine, and its very limited so i need a tutorial on whatever u used:)

Hey thanks! At first I was using 2D perlin, But then I changed to 3D simplex because it's smoother and you can also make caves/ores/water pockets... etc.. but I never published the simplex version as I never finished tweaking it, I got busier and got injured in my hand so I stopped using the computer overall haha.. I might put the updated version later on the next month, Idk, If you need help feel free to PM me and I can help you out with your game as I didn't really follow a tutorial, All the code is mine Smiley

 29 
 on: 2014-12-27 00:36:14 
Started by Dreamtime - Last post by Dreamtime
Thanks. Their forums are down or something, and for now they're using stackoverflow. No reply yet.

Trying to find how to attach zip.

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  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
import java.awt.*;
import java.awt.Component;
import java.awt.event.*;


public class Game
{
   Draw draw;
   Frame frame;
   Insets insets;
   
   boolean isRunning = true;  
   
   
   private int FPS = 30;
   private double averageFPS;
   
   public static void main(String[] args)
   {
      Game game = new Game();
      game.run();
      System.exit(0);
   }
   
   void run()
   {
      initialize();
     
      long startTime;
      long URDTimeMillis;
      long waitTime;
      long totalTime = 0;
     
      int frameCount = 0;
      int maxFrameCount = 30;
     
      long targetTime = 1000 / FPS;
     
      while(isRunning)
      {
         startTime = System.nanoTime();
         
         update();
         draw();
         
         URDTimeMillis = (System.nanoTime() - startTime) / 1000000;
         
         waitTime = targetTime - URDTimeMillis;
         
         try
         {
            Thread.sleep(waitTime);
         }
         catch(Exception e)
         {
         
         }
         
         totalTime += System.nanoTime() - startTime;
         frameCount++;
         
         if(frameCount == maxFrameCount)
         {
            averageFPS = 1000.0 / ((totalTime / frameCount) / 1000000);
            frameCount = 0;
            totalTime = 0;
         }
     
      }
     
      frame.close();
   }
   
   void initialize()
   {
     
     
      draw = new Draw();
      frame = new Frame();
     
      frame.add(draw);
   }
   
   void update()
   {}
   
   void draw()
   {
      frame.draw();
   }
}


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  
35  
import java.awt.*;
import javax.swing.*;
import java.awt.image.BufferedImage;
import javax.swing.JFrame;
import java.awt.Component;
import java.awt.event.*;

public class Frame extends JFrame
{
   int windowWidth = 960;
   int windowHeight = 480;
   Insets insets;
   
   public Frame()
   {
      setTitle("Game");
      setSize(windowWidth, windowHeight);
      setResizable(false);
      setDefaultCloseOperation(EXIT_ON_CLOSE);
      insets = getInsets();
      setSize(insets.left + windowWidth + insets.right, insets.top + windowHeight + insets.bottom);
     
      Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
      setLocation(dim.width/2-this.getSize().width/2, dim.height/2-this.getSize().height/2);
     
      setVisible(true);
   
   }

   
   public void close()
   {
      setVisible(false);
   }
}


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;

public class Draw extends JPanel
{
   public Draw()
   {
   
   }
   
   @Override
   protected void paintComponent(Graphics g)
   {
      super.paintComponent(g);
     
   }
   
   public void draw()
   {
      repaint();
   }
}


Just creates a window. After using jwrapper, the program runs but a window doesn't appear. I am following the instructions for the sample project and last night I was able to get that working, but translating to this is just doesn't run.

My project is called 'gametest'. Inside gametest there are two folders 'JRE-1.7' from extracting the jre pack. 'gameapp', contains game.jar (runs fine), jwrapper.xml, the sample logo/splash, two more folders, src and bin, bin class files, src source files.

XML:

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  
35  
36  
37  
38  
39  
<JWrapper>
   
   <!-- The name of the app bundle -->
   <BundleName>GameApp</BundleName>
   
   <!-- The specification for one app within the bundle -->
   <App>
     <Name>Game</Name>
     <LogoPNG>gameapp/logo.png</LogoPNG>
     <MainClass>Game</MainClass>
     <Param>one</Param>
     <Param>two</Param>
   </App>
   
   <SupportedLanguages>en</SupportedLanguages>
   
   <!-- App is a per-user app, it won't elevate and install for all users and the shared config folder will be per-user -->
   <InstallType>CurrentUser</InstallType>
   
   <!-- Splash and Logo -->
   <SplashPNG>gameapp/splash.png</SplashPNG>
   <BundleLogoPNG>gameapp/logo.png</BundleLogoPNG>
   
   <!-- JVM options (e.g. extra memory) -->
   <JvmOptions>
    <JvmOption>-Xmx256m</JvmOption>
   </JvmOptions>
   
   <!-- The JREs JWrapper should use for Windows, Linux32, Linux64... -->
   <Windows32JRE>JRE-1.7/win32/jre1.7.0_05</Windows32JRE>
   <Windows64JRE>JRE-1.7/win32/jre1.7.0_05</Windows64JRE>
   <Linux32JRE>JRE-1.7/linux/jre1.7.0_13</Linux32JRE>
   <Linux64JRE>JRE-1.7/linuxx64/jre1.7.0_13</Linux64JRE>
   <Mac64JRE>JRE-1.7/macos64/jre1.7.0_45.jre</Mac64JRE>

   <!-- The files that the app wants to bundle, here we have just one which is a JAR file and we specify that it should be on the launch classpath -->
   <File classpath='
yes'>gameapp/game.jar</File>
   
</JWrapper>


Edit: My manifest.txt for the jar file is just "Main-Class: Game"

 30 
 on: 2014-12-27 00:01:34 
Started by The Lion King - Last post by Mr.CodeIt
Maybe after January 1st or on the same day, one thing I ask is to give 10 days time for each JAM, we can get more quality games done in my opinion.
I personally think the 7 days are okay because it spices up your Monday a bit, but some people may be busy with some other things during the week so 8 - 10 days seems reasonable. That also changes the due date each week.

Pages: 1 2 [3] 4 5 ... 10
 

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

The first screenshot will be displayed as a thumbnail.

Mr.CodeIt (10 views)
2014-12-27 04:03:04

TheDudeFromCI (13 views)
2014-12-27 02:14:49

Mr.CodeIt (25 views)
2014-12-23 03:34:11

rwatson462 (56 views)
2014-12-15 09:26:44

Mr.CodeIt (46 views)
2014-12-14 19:50:38

BurntPizza (92 views)
2014-12-09 22:41:13

BurntPizza (113 views)
2014-12-08 04:46:31

JscottyBieshaar (83 views)
2014-12-05 12:39:02

SHC (94 views)
2014-12-03 16:27:13

CopyableCougar4 (102 views)
2014-11-29 21:32:03
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!