Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (429)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (468)
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]
  ignore  |  Print  
  How about some help, guys?  (Read 5961 times)
0 Members and 1 Guest are viewing this topic.
Offline grazi

Senior Newbie




Life > Games > All


« Reply #30 - Posted 2006-01-10 16:24:11 »

How come it seems like most folks use ints for everything? In the end does the JVM not account for the actual size difference between a int and short? And it seems like bit twiddling isn't really used anymore, why is that?

Jeff Olson
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #31 - Posted 2006-01-10 17:29:35 »

How come it seems like most folks use ints for everything? In the end does the JVM not account for the actual size difference between a int and short?

INTs are the natural size for numbers. Shorts and Bytes are converted to INTs at runtime, leaving little advantage to using a smaller number. Also, many games need greater precision that only an INT or LONG can provide.

Quote
And it seems like bit twiddling isn't really used anymore, why is that?

Depends on what you mean. SuperPackME does all kinds of bit twiddling, for example. But you have to be careful. It may actually cost you more in instructions to twiddle bits than it would to use a straight int (which is "free" on the stack anyway). Remember, we're targetting size, not memory. Smiley

Java Game Console Project
Last Journal Entry: 12/17/04
Offline Markus_Persson

JGO Wizard


Medals: 12
Projects: 19


Mojang Specifications


« Reply #32 - Posted 2006-01-10 20:18:21 »

ints and shorts (and bytes) both use the CONSTANT_Integer_info entries in the constant pool. =)

edit:

No, bytes don't seem to use the constant pool! Cheesy Makes sense.

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

Senior Newbie




Life > Games > All


« Reply #33 - Posted 2006-01-10 23:40:52 »

More so by bit twiddling I meant using ints to compact things into one value instead of storing massive amounts of data in seperate things... Take tiling for instance, if your trying to store a map and are storing a few tiles only across a map, can't you compact that map into a smaller space to be stored for us in the game as a resource by having ints hold multiple peices of information vs multiple ints for the same information? Just curious.

Jeff Olson
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 613
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #34 - Posted 2006-01-11 00:53:10 »

I had all locations of the suits on all cards for Poker4k, encoded in 1 long.

It was fun, but the bit-shifting overhead removed quite a lot of the benefit.

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

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #35 - Posted 2006-01-11 03:39:03 »

Take tiling for instance, if your trying to store a map and are storing a few tiles only across a map, can't you compact that map into a smaller space to be stored for us in the game as a resource by having ints hold multiple peices of information vs multiple ints for the same information? Just curious.

Of course. Like I said, SuperPackME is an excellent example of this. It reduces the number of colors in an image down to the absolute minimum necessary, then stores it in a bit-packed format. That bit-packed format is converted to a hex-string which is inserted into the class data. The resulting class compresses extremely well.

To extract the data, the hex codes are converted back into nibbles. The graphics data is then twiddled out of the nibbles to produce a list of pixels and their colors. The process is described in more detail here.

As for someone who stashes levels that way, I think Kevglass's rendition of Tower Toppler might have packed data at the bit level, but don't quote me on that. Many (most?) developers use procedurally generated levels to avoid the overhead of storing level data.

Does that better answer your question?

Java Game Console Project
Last Journal Entry: 12/17/04
Pages: 1 [2]
  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.

theagentd (6 views)
2014-04-24 23:00:44

xsi3rr4x (83 views)
2014-04-15 18:08:23

BurntPizza (75 views)
2014-04-15 03:46:01

UprightPath (86 views)
2014-04-14 17:39:50

UprightPath (69 views)
2014-04-14 17:35:47

Porlus (86 views)
2014-04-14 15:48:38

tom_mai78101 (109 views)
2014-04-10 04:04:31

BurntPizza (169 views)
2014-04-08 23:06:04

tom_mai78101 (265 views)
2014-04-05 13:34:39

trollwarrior1 (216 views)
2014-04-04 12:06:45
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!