Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (482)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (550)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Made my own basic library  (Read 2478 times)
0 Members and 1 Guest are viewing this topic.
Offline StonePickaxes

JGO Coder


Medals: 4
Projects: 2


Nathan Kramber


« Posted 2012-06-19 03:15:46 »

So, after about ten or twelve games made, I noticed that I was re-using a LOT of code from previous projects that usually ended up being the first thirty to forty minutes of every new project. I had heard of people making their own libraries before, and thought I might give it a try.

Anyways, after about two hours, I finally got the first usable version done, which feels awesome.
Now, if I use my library, I only need to right this code...

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
package com.natekramber;

import mylib.*;
import mylib.gfx.*;

public class Game extends BaseGame {
   public static void main(String[] args) {
      Game game = new Game();
      game.start();
   }
   
   public void start() {
      new Main(this, "title", 200, 100, 3);
   }
   
   public void tick() {
   }
   
   public void render() {
      Font.draw("Test", 40, 40, Col.get(0x00ffff));
   }
}


...to get this result...



I don't know why, but it feels really good to be able to get something up and running in one minute or less as opposed to thirty.

Cheers,
-Nathan

EDIT: Also, this is the game-loop I'm using...

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  
public void run() {
      long lastTime = System.nanoTime();
      double unprocessed = 0;
      double nsPerTick = 1000000000.0 / 60;
      int frames = 0;
      int ticks = 0;
      long lastTimer1 = System.currentTimeMillis();

      init();

      while (running) {
         long now = System.nanoTime();
         unprocessed += (now - lastTime) / nsPerTick;
         lastTime = now;

         while (unprocessed >= 1) {
            ticks++;
            tick();
            frames++;
            render();
            unprocessed = 0;
         }

         if (System.currentTimeMillis() - lastTimer1 > 1000) {
            lastTimer1 += 1000;
            System.out.println(ticks + " ticks, " + frames + " fps");
            frames = 0;
            ticks = 0;
         }
      }
      System.exit(0);
   }

Check out my website!
Offline Nate

JGO Kernel


Medals: 145
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #1 - Posted 2012-06-19 11:50:07 »

Soon, you'll never finish any games. Sad

Offline krasse
« Reply #2 - Posted 2012-06-19 12:02:58 »

Soon, you'll never finish any games. Sad

Smiley
It is true that when you start to think about creating an engine, you will soon start to think stuff like "I want to make this piece of code reusable", "This works, but it isn't general enough". All these thougths will make you start to see all sorts of problems that aren't really there and then you quickly lose the fun-factor.

Or perhaps not... You have finished 10-12 games already so you are in pretty good shape Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Damocles
« Reply #3 - Posted 2012-06-19 12:24:45 »

I find it more productive to just have a collection of example-codes and skeletoncodes, -> to copy/past
them together for a new project.

This reusability stuff does not fit for gamedevelopment.
It has its place in corporate software design, but a game is
hardly a standard and reusable component.

Every time you try so make things reusable, you have to agree on
a common (mostly virtual) denominator.
-> and this is often not representing the efficient solution for the current task.

Where it make sense is in "Toolbox codes" such as loading assets
or specific technical frameworks such as playing sound.

Where I see a sense in making a really deep game-engine / framework is
when you have to "spit out" many small games in a short cycle that share many mechanics, or you have to develop in paralel for
different platforms (Android, JavaME, Desktop)
Such that the core classes can be ported quickly.

Offline badlogicgames
« Reply #4 - Posted 2012-06-19 13:58:28 »

Welcome to the circle of "never getting paying shit done" Cheesy

http://www.badlogicgames.com - musings on Android and Java game development
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 76
Projects: 15


★★★★★


« Reply #5 - Posted 2012-06-19 14:09:06 »

@StonePickaxes nice, looks similar to what existing framework libraries like Slick2D, LibGDX provide, maybe you should just use an existing framework library?
Offline h3ckboy

JGO Coder


Medals: 5



« Reply #6 - Posted 2012-06-19 14:16:38 »

kappa, while those may exist and are fantastic, I personally find it much better to do it all on my own (thats just me personally, maybe stonepickaxe feels differnt), then I don't have to worry about lack of features or too many useless features, etc. etc. also if someting breaks, I can fix it, rather than posting to kev, and just pray that he is on that evening Tongue (don't get me wrong he has done an awesome job Smiley )

just my opinion Tongue.
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 76
Projects: 15


★★★★★


« Reply #7 - Posted 2012-06-19 14:30:29 »

sounds like a case of NIH Syndrome Smiley
Offline StonePickaxes

JGO Coder


Medals: 4
Projects: 2


Nathan Kramber


« Reply #8 - Posted 2012-06-19 15:25:20 »

@StonePickaxes nice, looks similar to what existing framework libraries like Slick2D, LibGDX provide, maybe you should just use an existing framework library?

I like the idea of using a library that already exists and is well-developed, but I want to see if I can do it on my own. Smiley

-Nathan

Check out my website!
Offline h3ckboy

JGO Coder


Medals: 5



« Reply #9 - Posted 2012-06-19 15:27:31 »

hahaha, yeah I guess, but I think my reasoning is understandable.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline sproingie

JGO Kernel


Medals: 202



« Reply #10 - Posted 2012-06-19 15:42:15 »

Soon, you'll never finish any games. Sad

Welcome to the circle of "never getting paying shit done" Cheesy

Bah.  He's doing a library the right way, by factoring out code from stuff he's already written.  Sure it's still possible to get mired in tinkering with such a library, but it's way less likely.

Offline ra4king

JGO Kernel


Medals: 345
Projects: 2
Exp: 5 years


I'm the King!


« Reply #11 - Posted 2012-06-19 18:13:09 »

Take it from me, as soon as I finished JDoodle Jump, I also noticed lots of potential reusable code, which I just factored out into a similar tiny library........which soon became a huge library full of awesome classes........with almost no games done since then........ yeah, don't do it Sad

Offline R.D.

Senior Member


Medals: 2
Projects: 1


"For the last time, Hats ARE Awesome"


« Reply #12 - Posted 2012-06-19 18:18:31 »

Nice! It's really great to have some sort of library to make use of common stuff. I do that too (*hint* signature). I also like using Slick2D but it has some stuff I really miss in this Engine (like exchanging data between states, managed primitves and so on). As I made some games in Slick2D I always found the same code and now I make an Engine from it. Even with powerful debug tools with TWL.
Offline StonePickaxes

JGO Coder


Medals: 4
Projects: 2


Nathan Kramber


« Reply #13 - Posted 2012-06-19 19:26:38 »

Take it from me, as soon as I finished JDoodle Jump, I also noticed lots of potential reusable code, which I just factored out into a similar tiny library........which soon became a huge library full of awesome classes........with almost no games done since then........ yeah, don't do it Sad

But I don't really care about pushing games out. At this point, what matters to me is learning as much as possible before I start working so that

A: I can get a good job
and B: So that I can make games during my free time when I am an adult without having to learn everything.

Plus, I like doing this. It's challenging me in a different way. Smiley

On a side note, I just got done writing this cool class to do "Gradual text scrolling". I wonder what I could use this for?

-Nathan

Check out my website!
Offline ags1

JGO Ninja


Medals: 47
Projects: 2
Exp: 5 years


Make code not war!


« Reply #14 - Posted 2012-06-19 21:07:41 »

You have finished 10-12 games already so you are in pretty good shape Smiley

Amazing - actually losing count of the number of games you have written!

Offline ra4king

JGO Kernel


Medals: 345
Projects: 2
Exp: 5 years


I'm the King!


« Reply #15 - Posted 2012-06-19 21:58:37 »

On a side note, I just got done writing this cool class to do "Gradual text scrolling". I wonder what I could use this for?

-Nathan
I'm scared....... oh and you misspelled thought* Grin

Offline StonePickaxes

JGO Coder


Medals: 4
Projects: 2


Nathan Kramber


« Reply #16 - Posted 2012-06-19 22:24:40 »

On a side note, I just got done writing this cool class to do "Gradual text scrolling". I wonder what I could use this for?

-Nathan
I'm scared....... oh and you misspelled thought* Grin

FFFFFFFUUUUUUUUUU

Just kidding. I would be mad if this was a release of an actual game and I had to fix it, but since it was pretty useless as-is..



-Nathan

Check out my website!
Offline ra4king

JGO Kernel


Medals: 345
Projects: 2
Exp: 5 years


I'm the King!


« Reply #17 - Posted 2012-06-20 00:56:01 »

Nah bro....I can tell.....umad... Wink

Offline ReBirth
« Reply #18 - Posted 2012-06-22 03:54:10 »

It's evil, but I need it. So I'll let others do it. Then, I just use it.

Offline davedes
« Reply #19 - Posted 2012-06-22 04:04:47 »

Screw making games. Libraries and engines are where it's at. Grin

I was working on one myself -- a minimal 2D API utilizing "modern" GL -- before I got sidetracked by a job. It's a great way to learn what's going on behind the scenes, and will dramatically improve the way you program games in the future. Smiley

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

CopyableCougar4 (14 views)
2014-08-22 19:31:30

atombrot (28 views)
2014-08-19 09:29:53

Tekkerue (25 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (15 views)
2014-08-16 06:20:21

Tekkerue (22 views)
2014-08-16 06:12:11

Rayexar (61 views)
2014-08-11 02:49:23

BurntPizza (39 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38
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!