Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
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]
  ignore  |  Print  
  Many many different things. Here is the example.  (Read 5041 times)
0 Members and 1 Guest are viewing this topic.
Offline m77

« In padded room »

« Posted 2008-05-17 22:51:27 »

import java.io.*;

public class Pair implements Serializable {
  public Object o1;
  public Object o2;

  public Pair(Object o1, Object o2) {
    this.o1=o1;
    this.o2=o2;
  }
}


Here http://btrgame.com/dev/srconline.jsp are full the package.
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #1 - Posted 2008-05-18 00:26:33 »

Uh... can you be more descriptive with this?

See my work:
OTC Software
Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #2 - Posted 2008-05-18 07:28:21 »

I thought it was pretty self-explanatory, but then again, I also have several years of training doing this java stuff  Wink

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #3 - Posted 2008-05-18 08:28:53 »

I thought it was pretty self-explanatory, but then again, I also have several years of training doing this java stuff  Wink
Well if I read the source he has attached I can figure it out, but I don't see how his example is too indicative of anything.

See my work:
OTC Software
Offline m77

« In padded room »

« Reply #4 - Posted 2008-05-18 12:21:01 »

Well if I read the source he has attached I can figure it out, but I don't see how his example is too indicative of anything.

Are you disagree that Pair is short and usefull class? How your method returns x and y for example? In array of doubles with 2 elements? Or you will write special class? Point2D. Look there at m.util package. Most usefull things for common deeds are there.
Offline cylab

JGO Ninja


Medals: 55



« Reply #5 - Posted 2008-05-18 18:47:05 »

Demonpants (and I)  just think your example is not a good indication of the scope of your utilities. So a descriptive summary about what can be found in your utilities would have been more insightfull than this code snippet.

Mathias - I Know What [you] Did Last Summer!
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #6 - Posted 2008-05-18 21:38:21 »

Yes, exactly. I would expect something more along the lines of:

"This is a package of code which includes drawing functions, physics utilities, and geometric calculations for use with games in Java applets."

See my work:
OTC Software
Offline m77

« In padded room »

« Reply #7 - Posted 2008-05-20 07:14:35 »

  public static final void printStackTrace() {
    try {
      throw new RuntimeException("StackTraceGetter");
    } catch(Exception e) {
      e.printStackTrace();
    }
  }


another one bites the dust...
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #8 - Posted 2008-05-20 08:41:36 »

  public static final void printStackTrace() {
    try {
      throw new RuntimeException("StackTraceGetter");
    } catch(Exception e) {
      e.printStackTrace();
    }
  }


another one bites the dust...

Thread.dumpStack()

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline m77

« In padded room »

« Reply #9 - Posted 2008-05-20 20:20:56 »


hahaha
and what about
  public static int max(int[] arr) {
    int max=0;
    for (int i=1; i<arr.length; i++) {
      if (arr > arr[max]) {
        max=i;
      }
    }
    return max;
  }
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline noblemaster

« JGO Spiffy Duke »


Medals: 20
Projects: 10


Age of Conquest makes your day!


« Reply #10 - Posted 2008-05-20 20:25:38 »

1  
2  
3  
public int getAnswerToLife() {
  return 42;
}


 Grin

Online Riven
« League of Dukes »

« JGO Overlord »


Medals: 841
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #11 - Posted 2008-05-20 21:00:12 »

1  
2  
3  
4  
5  
6  
7  
8  
9  
  public static int max(int[] arr) {
    int max=0;
    for (int i=1; i<arr.length; i++) {
      if (arr[i] > arr[max]) {
        max=i;
      }
    }
    return max;
  }


this is like indexOfMax(..), not max(...)

further, it doesn't handle the cornercase where arr.length==0 properly: it should return -1

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social
Offline noblemaster

« JGO Spiffy Duke »


Medals: 20
Projects: 10


Age of Conquest makes your day!


« Reply #12 - Posted 2008-05-20 23:04:18 »

Quote
indexOfMax(..)
furthermore, it's rather firstIndexOfMax(....

Offline Markus_Persson

JGO Wizard


Medals: 16
Projects: 19


Mojang Specifications


« Reply #13 - Posted 2008-05-21 14:43:13 »

Thanks for sharing your code. =)

Your initial post seems to indicate you're sharing some kind of library for doing trivial things with fewer lines of code, but when visiting the site, it appears to be the source code for your game, Battery.
While some of the code could possibly be useful, it's not really suitable as a library. The naming is confusing, so there's no way of telling what's where, which means it's probably faster to write your own indexOfMax loop than to look through your code to see if you've written something like that already.

Many of the functions are totally pointless, sometimes entire classes are, and what's even worse, sometimes they're both pointless and WRONG.
For example:
1  
2  
3  
  public static final double angle(double x, double y) {
    return Math.atan2(x, y);
  }


That would be fine, except it's easier to type Math.atan2(x, y) than m.util.U77.angle(x, y), and the fact that Math.atan2 takes y, x, not x, y.
Now, if you use angle() like atan() and pass y, x, you  get the right results, but the code seems to indicate you should pass x first.

The code is ok, if a bit rough, and it's interesting to see what solutions you've used in your game, but a good library of easy to use functions, it is not.

Play Minecraft!
Offline m77

« In padded room »

« Reply #14 - Posted 2008-05-21 18:42:51 »

Markus, mathematicans could disagree with me but for me angle starts from zero on clocks and grows as hours or minutes...
with angle() method i get exactly what i want. tell me please more wrong methods and classes.
Offline Markus_Persson

JGO Wizard


Medals: 16
Projects: 19


Mojang Specifications


« Reply #15 - Posted 2008-05-22 12:35:05 »

Markus, mathematicans could disagree with me but for me angle starts from zero on clocks and grows as hours or minutes...
with angle() method i get exactly what i want. tell me please more wrong methods and classes.

Actually, I can't find anything else that's outright wrong, so I apologize for implying there are more errors. Sorry.

About atan2: If it works for your project, then it's great. I myself also use Math.atan2(x, y) in my projects, but I also always get sin and cos mixed up.
I just meant for a library, it's probably a good idea to pay very close attention to the standards. =)


Some minor feedback:

You should move all packages from m.* to com.btrgame.*. It's not insanely important, but if several people make libraries in the m.* package, things will get confusing, that's why there's a package name standard.

Catching compile time errors and throwing runtime errors instead is.. well.. Some people think it's valid style, but I strongly disagree. It's much better than empty catch blocks, though.
What's worse, often you catch Exception and just return false or null.. that will lead to bugs as it forces the people who use your code to do manual error checking, or just get silent failures. Failures should be LOUD.

m.util.File77.copy(String, String) is very, very slow as it reads and writes a single byte at a time.
1  
2  
3  
4  
byte[] buffer = new byte[BUFFER_SIZE];
int bytesRead= 0;
while ((bytesRead=in.read(buffer))!=-1)
    out.write(buffer, 0, bytesRead);


m.util.File77.delete(String) is dangerous as all hell. Wink

m.util.U77.repeat(String, int) is very slow. "res += s" is the same as "StringBuffer tmp = new StringBuffer(res); tmp.append(s); res = tmp.toString();"
This probably will never matter in your game, but if someone writes something that relies on it, I'm sure they'd appreciate it if it was faster:
1  
2  
3  
StringBuffer res=new StringBuffer();
for (int i=0; i<count; i++) res.append(s);
return res.toString();

Play Minecraft!
Offline m77

« In padded room »

« Reply #16 - Posted 2008-05-22 13:33:14 »

Thanks, Markus.

Have you got my mail?
Offline Markus_Persson

JGO Wizard


Medals: 16
Projects: 19


Mojang Specifications


« Reply #17 - Posted 2008-05-22 14:44:40 »

Yes, I did. Unfortunately, I can't seem to send any emails any more, so I can't reply.

I don't have enough free time to join a project right now, what little time I've got, I spend on my own silly projects and on gaming (gta4 and tf2, baby!)

Play Minecraft!
Offline m77

« In padded room »

« Reply #18 - Posted 2008-05-22 16:30:03 »

I spend on my own silly projects and on gaming (gta4 and tf2, baby!)

Tf2==Turtles Fighter 2?  Cheesy <- i love this unhealthy smile Cheesy
Offline g666

Junior Devvie





« Reply #19 - Posted 2008-05-22 17:43:19 »

Team Fortress 2 i imagine

desperately seeking sanity
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.

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

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

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

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

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

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

CopyableCougar4 (60 views)
2014-11-29 21:32:03

toopeicgaming1999 (123 views)
2014-11-26 15:22:04

toopeicgaming1999 (114 views)
2014-11-26 15:20:36

toopeicgaming1999 (32 views)
2014-11-26 15:20:08
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!