Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
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  
  Would this be too many images?  (Read 4010 times)
0 Members and 1 Guest are viewing this topic.
Offline Dream Of Sleeping
« Posted 2012-03-18 23:28:03 »

Sorry to post two topics in the same day.

I have an idea for a game that I want to make. It's a maths game. And I want it to have the appearence of chalk being on a blackboard. I thought I might buy a real small blackboard and some chalk and create the images from taking photos.

The thing I'm concerned about is, if I have some of the text done this way, then ALL of the text has to be done this way. And I wondering if this would end up making the applet  take a ridiculously long time to load. Off the top of my head these are a list of images I will need to make

The blackboard background
numbers from 0 to 9
+
-
X
[ ]
=
Hi Score
Score
Time
Mins
Secs
Play
Level
New Numbers
some kind of grid for the numbers to go in.
a brush


So that's 26 and I've probably forgot about a few. Would that be classed as a lot of images? Would you recommend just using white font instead? Or is there some other fancy way that I don't know about?

Offline GabrielBailey74
« Reply #1 - Posted 2012-03-18 23:35:05 »

In Java Graphics2D you can always change the font Size, and Type, from Bold, Italic, Plain, and the color of course.
You could also first try it the way you think it will work, and if it doesn't look for a more suitable method.
I usually call loading all my Images right as the Jframe's being setVisible, or in the Constructor of the first class being called and I don't receive starting lag.

Offline Dream Of Sleeping
« Reply #2 - Posted 2012-03-18 23:42:47 »

In Java Graphics2D you can always change the font Size, and Type, from Bold, Italic, Plain, and the color of course.
You could also first try it the way you think it will work, and if it doesn't look for a more suitable method.
I usually call loading all my Images right as the Jframe's being setVisible, or in the Constructor of the first class being called and I don't receive starting lag.

How many images do you tend to load? Do you think 26 or so images is classed as a lot of images? I have no real reference point. It will be my first applet.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline GabrielBailey74
« Reply #3 - Posted 2012-03-18 23:52:50 »

Here's a snippet of the Graphics launch of my program (After the applets prepped) loading the Animation Frames + Transparent Images, i'll post all the code so you can see / count O.o.

(Counted: 17) XD
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
   public GraphicsClass(Game game) {
      texture = new TextureLoader(this);
      tploader = new TransparentLoader();
      p = Client.p;
      GraphicsClass.gam = game;
      try {
         TransparentLoader.makeTransparents();
         loadFireImages1();
         loadFireImages2();
      } catch (Exception e) {
         e.printStackTrace();
      }
   }


Than calls to load the fireImages (1,2):
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  
   public static void loadFireImages1() {
      tempImg = new ImageIcon("res/icons/fire1.png").getImage();
      fireFrames1[0] = tempImg;
      tempImg = new ImageIcon("res/icons/fire1.png").getImage();
      fireFrames1[1] = tempImg;
      tempImg = new ImageIcon("res/icons/fire2.png").getImage();
      fireFrames1[2] = tempImg;
      tempImg = new ImageIcon("res/icons/fire2.png").getImage();
      fireFrames1[3] = tempImg;
      tempImg = new ImageIcon("res/icons/fire3.png").getImage();
      fireFrames1[4] = tempImg;
      tempImg = new ImageIcon("res/icons/fire3.png").getImage();
      fireFrames1[5] = tempImg;
   }

   public static void loadFireImages2() {
      tempImg = TransparentLoader.fireIcon1;
      fireFrames2[0] = tempImg;
      tempImg = TransparentLoader.fireIcon1;
      fireFrames2[1] = tempImg;
      tempImg = TransparentLoader.fireIcon2;
      fireFrames2[2] = tempImg;
      tempImg = TransparentLoader.fireIcon2;
      fireFrames2[3] = tempImg;
      tempImg = TransparentLoader.fireIcon3;
      fireFrames2[4] = tempImg;
      tempImg = TransparentLoader.fireIcon3;
      fireFrames2[5] = tempImg;
   }


And finally loading the Transparent Images:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
   public static void makeTransparents() throws Exception {
      try {
         BufferedImage tmp0 = ImageIO.read(new File( "res/sprites/southwall.png"));
         BufferedImage tmp1 = ImageIO.read(new File( "res/sprites/eastwall.png"));
         BufferedImage tmp2 = ImageIO.read(new File("res/icons/fire1.png"));
         BufferedImage tmp3 = ImageIO.read(new File("res/icons/fire2.png"));
         BufferedImage tmp4 = ImageIO.read(new File("res/icons/fire3.png"));
         southWall = makeTransparent(tmp0);
         eastWall = makeTransparent(tmp1);
         fireIcon1 = makeTransparent(tmp2);
         fireIcon2 = makeTransparent(tmp3);
         fireIcon3 = makeTransparent(tmp4);
      } catch (FileNotFoundException e3) {
         System.out.println("File not found.");
         e3.printStackTrace();
      }
   }


My game's completely loaded, start screen, input handlers active etc in under 3 seconds.
(Honestly if I dugg around in my Game Classes i'd probably find a good 7+ more images)

Offline davedes
« Reply #4 - Posted 2012-03-19 00:00:31 »

How big is each image?

IMO a better way to do this would be to render a bitmap font (see TWL's theme editor or Slick's Hiero) from a "chalkboard" font you find online. You can further refine the font in Photoshop (i.e. using a grunge brush to adjust its alpha). Then you would render a background chalkboard, and the font over top with whatever you'd like it to say.

Downsides:
- You would have to load the Bitmap Font and its glyph/kerning info then draw them manually
- You couldn't use dynamic font sizes without noticeable scaling artifacts
- Your text will look more "computer generated" (or cartoonish) -- if you are aiming for photo-realism, the effect will be lost

Upsides:
- You have full control over the digital aesthetic of the font; i.e. using Photoshop
- You also have more control over the aesthetic of the blackboard background, as it's now a separate element
- You can have the text say anything (i.e. for multiple languages)
- You can easily layer the numbers, text, grid, etc. on top of the blackboard (this would be tough if you're taking photos)
- Way faster loading time
- Smaller distribution size
- Most likely faster rendering performance

Also, regarding the photo idea, think about how much time you'll have to spend lining up your camera, setting up lights (to ensure consistency), etc. That's a lot of work, and it will probably turn out pretty cheesy.

Offline Dream Of Sleeping
« Reply #5 - Posted 2012-03-19 00:12:35 »

How big is each image?


I haven't made them yet.

Thanks for all that great information. I hadn't even heard of bitmap font so it seems like I have a lot of learning to do.

Offline GabrielBailey74
« Reply #6 - Posted 2012-03-19 00:15:30 »

How big is each image?


I haven't made them yet.

Thanks for all that great information. I hadn't even heard of bitmap font so it seems like I have a lot of learning to do.

Ah, if you scroll through this post you'll see what you'd sort of have to do, he tried rendering custom fonts:
(Towards the bottom)
http://www.java-gaming.org/topics/transparancy-fairly-simple/25711/msg/222564/view.html#msg222564

Offline Dream Of Sleeping
« Reply #7 - Posted 2012-03-19 00:23:34 »

Thanks I'll check it out.

Offline Dream Of Sleeping
« Reply #8 - Posted 2012-03-19 11:29:21 »

I've checked out a bitmap font tutorial, and although it is undoubtedly the best option, it looks so complicated to do. And as this is supposed to be my first applet, my first game that I designed myself. The bit map font thing makes it  all just a bit too overwhelming. So I might do it with images. I won't bother with the photos, but I'll just make simply drawings of letters in gimp. When I've finished the game I'll revisit looking at bitmap fonts.


I'm trying to think of cunning ways I can cut down on the amount of images I use like I might add some of the text, like high score, to the background image it's self to make it have less images. If there was some elegant way I could just have the blackboard for the main numbers and sums, and have the play again buttons and level menus not on the board, then I could use normal font for them. But then that would mean loading another big background image, because it might look weird having normal font on the blackboard. I think I need to cut myself some slack, it's my first real game, it's allowed to look a bit crap. lol

Offline StumpyStrust
« Reply #9 - Posted 2012-03-19 11:46:48 »

hmmm 26 images still is not that much from what I understand. I load many it the only slow down is the getsubimage method

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Screem
« Reply #10 - Posted 2012-03-19 15:08:34 »

I'm making a game and tested out how many images I can render onto the screen without too much lag. The lag started at around 100-150 images (all 8x8 pixels in size; scaled up to 24x24 when rendered) so 26 images shouldn't be so much of a problem. All the images were saved into a HashMap when loaded, so the only call when rendering the images onto the screen is graphics.drawImage().

Offline Dream Of Sleeping
« Reply #11 - Posted 2012-03-19 17:44:49 »

I'm making a game and tested out how many images I can render onto the screen without too much lag. The lag started at around 100-150 images (all 8x8 pixels in size; scaled up to 24x24 when rendered) so 26 images shouldn't be so much of a problem. All the images were saved into a HashMap when loaded, so the only call when rendering the images onto the screen is graphics.drawImage().

My main concern was how long it took to load the images in an applet. I never really gave much thought about the all images I will be rendering. The numbers will be a 6 by 6 grid, so that's 36 before I even start counting all the others!

I have read that scaling the image slows drawing down, so maybe that slowed down your program. Out of curiosity, why did you scale up to 24x24 rather than just make 24x24 images?

I've made tetris games where the pieces were made up of individual blocks, so there were loads on screen. I didn't test the frame rate though, and it wasn't an applet.

Offline StumpyStrust
« Reply #12 - Posted 2012-03-19 20:13:30 »

In my particle system stress testing I see drops in performance at over 1-2k images with alpha blending. So....you should be fine. As far as loading time goes, my games/tests load almost instantly as long as getsubimage is never called.

I call it to load srpite strips into a bufferedimage array so I don't have to draw with getsubimage because its so slow.

Offline Screem
« Reply #13 - Posted 2012-03-19 20:44:01 »

I'm making a game and tested out how many images I can render onto the screen without too much lag. The lag started at around 100-150 images (all 8x8 pixels in size; scaled up to 24x24 when rendered) so 26 images shouldn't be so much of a problem. All the images were saved into a HashMap when loaded, so the only call when rendering the images onto the screen is graphics.drawImage().

My main concern was how long it took to load the images in an applet. I never really gave much thought about the all images I will be rendering. The numbers will be a 6 by 6 grid, so that's 36 before I even start counting all the others!

I have read that scaling the image slows drawing down, so maybe that slowed down your program. Out of curiosity, why did you scale up to 24x24 rather than just make 24x24 images?

I've made tetris games where the pieces were made up of individual blocks, so there were loads on screen. I didn't test the frame rate though, and it wasn't an applet.

I'm not quite sure how fast it would be on an applet, as I've never really experimented with them. Undecided

I used 8x8 images since I want the game to have a pixelated effect, and the size of the images stored in the HashMap would be smaller and (I think) less memory. In total I have 1024 images stored in a HashMap at runtime by calling getSubImage() for each tile in the sprite sheet, and the game loads in < 2-3 seconds. The sprite sheet has a grid of 32x32 tiles; all of which are 8x8 pixels in length and height.

Offline StumpyStrust
« Reply #14 - Posted 2012-03-19 21:10:49 »

Should be ok. I would not worry until you start to see fps drop. Also, from my experiences .getsubimage is unholyly slow.

Offline ra4king

JGO Kernel


Medals: 322
Projects: 2
Exp: 4 years


I'm the King!


« Reply #15 - Posted 2012-03-20 06:37:45 »

.getsubimage is unholyly slow.
I don't know what you're talking about but getSubimage is blazingly fast.

Offline loom_weaver

JGO Coder


Medals: 17



« Reply #16 - Posted 2012-03-20 07:11:55 »

I'm making a game and tested out how many images I can render onto the screen without too much lag. The lag started at around 100-150 images (all 8x8 pixels in size; scaled up to 24x24 when rendered) so 26 images shouldn't be so much of a problem. All the images were saved into a HashMap when loaded, so the only call when rendering the images onto the screen is graphics.drawImage().

In my experience I could render about 1500 small images at 20 fps or greater using Java 2D.

Switching to OpenGL allowed me to render about 15k at the same frame-rate.

If you are experience lag with < 100 images then I would really look to ensure that they're all managed.  Scaling an image would automatically cause it to be unmanaged.
Offline StumpyStrust
« Reply #17 - Posted 2012-03-20 07:32:04 »

Hmm...I only use it at start up to load images from a sheet into an array so I can animate or randomly pick a images for particle FX. And when I just load it with out using getsubimage it loads instantly. Maybe I am doing something wrong. Idk. I have just had bad experiences using it.

I am using I think java 1.6 or 1.5 not 1.7 though.

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.

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

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

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

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

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

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

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

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

trollwarrior1 (204 views)
2014-04-04 12:06:45

CJLetsGame (211 views)
2014-04-01 02:16:10
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!