Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Java Game APIs & Engines / J2ME / Re: old-school scrolltext using bitmapped fonts. How? on: 2007-10-06 12:34:47
GREAT got it working  Cool . Though its scrolling badly slowly.  I am employing double buffering.  The code is chunky, ineffecient etc. For now its a great achievement to me  Cheesy.

Download Netbeans 5.5 project here -->  http://swartskaap.googlepages.com/j2me_scrolltext01.rar


this is double buffer helper class;
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  
/*
 * clsBackBuffer.java
 *
 * Created on 6 oktober 2007, 11:18
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */


package AmigaScrollerEenvoudig01;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;

/**
 *
 * @author Michiel Erasmus
 */

public class clsBackBuffer {
    private String CLASS_NAME = "clsBackBuffer";
    private Graphics graphics1;
    private Image backBuffer;
    public int backBufferHeight;
    public int backBufferWidth;
   
    /** Creates a new instance of clsBackBuffer */
    public clsBackBuffer(int bufferWidth, int bufferHeight) {
        this.graphics1 = null;
        this.backBuffer = Image.createImage(bufferWidth, bufferHeight);
        this.graphics1  = backBuffer.getGraphics();
    }
   
    /** Build up the back double buffer */
    public void addSprite(Sprite sprite1) throws Exception
    {
        String METHOD_NAME = "drawFrame";
       
        try
        {
            sprite1.paint(this.graphics1);
        } catch (Exception objErr1) {
            String strMelding2 = objErr1.getMessage();
            throw new Exception("  Fout in " + CLASS_NAME + "." + METHOD_NAME + " --> " + strMelding2);
        }
    }
   
    public Image getBackbuffer() throws Exception
    {
        return this.backBuffer;
    }
}
2  Java Game APIs & Engines / J2ME / Re: old-school scrolltext using bitmapped fonts. How? on: 2007-10-06 11:05:02
here  is a screenshot about what happens;


3  Java Game APIs & Engines / J2ME / Re: old-school scrolltext using bitmapped fonts. How? on: 2007-10-05 16:58:44
@SimonH thanx for the example of SetClip.
@Overkill, thanx your idea for sprite works great. 

The text scrolls Smiley.  Using a Spirte class and giving the tilewidth, heigh 32x32 the correct tile ("letter") is indeed take from the tiledmap.  However now a problem happens, that the letters are painted on screen causing 'smudging'.   Is setClip meant to fix that smudging?



So how I might do it:
Use Simons Midlet and Canvas classes
* add a Sprite class that handles the rendering of the tiles.
  this class should get the loaded image and the col- and row count and from that init all data
  the paint method should get the graphics context, position info and the col/row or an index you then generate col/row from.
  (then you have a good general purpose sprite class you can reuse)



  the paint method could look similar to the example I had pasted.

then when your midlet is running and paint is called you do
* loop through the letters and get their image indexes
* call the sprite class' paint method and pass it the graphics context, position and index/cell/row information.

Good idea to also reset the clip to the screen size after you call mehods that might change the clip, seeing as there is no reset-clip-method.


here is my new Paint() method.

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  
    /** paint the current animation frame */
     private void Paint(clsLettertje objLettertje)  throws Exception
    {
        String METHOD_NAME = "Paint";
       
        if(objLettertje == null)
        {  
            return;
        }
       
        if(this.graphics1 != null)
        {            
            try {
                clsLetterInMatrix displayObjInfo2 = this.GetLetterPosInTiledImage(objLettertje.TekstWaarde);
               
                if(displayObjInfo2 != null)
                {
                    this.graphics1.copyArea(0, 0, this.MidledWidth, this.MidledHeight, 0, 1, graphics1.TOP | graphics1.LEFT);
                    this.graphics1.setColor( 255, 255, 255 );
                    this.graphics1.drawRect(0, 0, this.MidledWidth, this.MidledHeight);
                    // plak die lettertje op scherm.
                   Image imgTilemap1 = objLettertje.image.getImage();
                    Sprite sprite1 = new Sprite(imgTilemap1, 32, 32);
                    sprite1.setFrame(displayObjInfo2.frameNumber);
                    sprite1.setPosition(objLettertje.CurrPosX1, objLettertje.CurrPosY1);
                    sprite1.paint(this.graphics1);[/i]                }
            } catch (Exception objErr1) {
                String strMelding2 = objErr1.getMessage();
                throw new Exception("  Fout in " + CLASS_NAME + "." + METHOD_NAME + " --> " + strMelding2);
            }
            //'this.graphics1.drawImage(objLettertje.image.getImage(), objLettertje.CurrPosX1, objLettertje.CurrPosY1, 0);
       }
    }

4  Java Game APIs & Engines / J2ME / Re: old-school scrolltext using bitmapped fonts. How? on: 2007-10-02 17:40:20
This is my first attempt at doing anything with Java.  This bedroom-rpogrammer idea is to recreate the ol' 8-/16-bit scrolltext found on AMiGA, Commodre64 etc. but then do it on J2ME.

My code need to more or less do the following;
1. Read a text string into an array.
2. Associate each letter (element) in the array with an appropriate letter.
3. Draw all letters after each other on displayarea (the screen) from left to right.
4. Shift all X-positions of the letters a few pixels to left.
5. Repeat (3) until the last letter has disappeared to the left side of the screen.

The aforementioned is no problem coz such is running in a window$ BlitzMax .exe already.  See earlier post for a screenshot.  My problem is step (2) and (3) in the above process.  Blitzmax have a neat feature that it handles tiledbitmaps nifty:

BlitzMax-code;
1  
2  
3  
Function paint()
  DrawImage(imgTiledImage, Xpos, Ypos, frames, tileWidth, tileHeight, tileNumber); '//this way just
Endfunction


Some info's;
The tiled bitmap (see earlier post) containing my font is 320 x 288  Pixels.
The letters are each 32x32 big.

To draw '#' the third letter from the top in the bitmap must be taken.
I just cant get getclip() to work the way it apparentley could.  There is drawn sumthing wrong or nothing.


this is a sample of my javacode, which should emulate the BlitzMax functionality;
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  
        
   /** paint the current animation frame */
     private void Paint(clsLettertje objLettertje)  throws Exception
    {
        String METHOD_NAME = "Paint";
       
        if(objLettertje == null)
        {  
            return;
        }
       
        if(this.graphics1 != null)
        {
            try {
                clsLetterInMatrix displayObjInfo2 = this.GetLetterPosInTiledImage(objLettertje.TekstWaarde);
               
                if(displayObjInfo2 != null)
                {
                    clsTiledImage tiledimg1 = new clsTiledImage(this.graphics1);
                    tiledimg1.setImage(objLettertje.image.getImage());
                    tiledimg1.tileHeight = 32;
                    tiledimg1.tileWidth = 32;
                    tiledimg1.drawFrame(displayObjInfo2.Kolom, displayObjInfo2.Rij, 40, 20);
                }
            } catch (Exception objErr1) {
                String strMelding2 = objErr1.getMessage();
                throw new Exception("  Fout in " + CLASS_NAME + "." + METHOD_NAME + " --> " + strMelding2);
            }
            //'this.graphics1.drawImage(objLettertje.image.getImage(), objLettertje.CurrPosX1, objLettertje.CurrPosY1, 0);
       }
    }


The method drawFrame uses the code frm earlier post.  If the program code could produce a scrolltext on the emulator it should probably be run on my Samsung E900 as well .  My dev environment is Netbeans 5.5 with J2ME kit installed.

This should be sumthing trivial. 
5  Java Game APIs & Engines / J2ME / Re: old-school scrolltext using bitmapped fonts. How? on: 2007-09-26 20:10:22
http://www.java-gaming.org/forums/index.php?action=post;topic=17434.0;num_replies=1

Great tip Smiley.  BUT, the java compiler dont know about setClip. My project is J2ME in netbeans 5.5.  I am quite proficient at C# but really n00b with java.

Is my code missing a library?


Netbeans 5.5 generates this error (the line numbers above wont match here Wink )
1  
2  
3  
4  
5  
Compiling 12 source files to C:\michiele\Programmering\Java\J2ME\Sandput\scrolltext01\build\compiled
C:\michiele\Programmering\Java\J2ME\Sandput\scrolltext01\src\AmigaScrollerEenvoudig01\clsTiledImage.java:37: cannot find symbol
symbol  : method setclip(int,int,int,int)
location: class AmigaScrollerEenvoudig01.clsTiledImage
        setclip( x, y, tileWidth, tileHeight);


here is example code;

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  
/*
 * clsLettertjes.java
 *
 * Created on 30 augustus 2007, 12:14
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */


package AmigaScrollerEenvoudig01;

import java.util.*;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
import pappavis.routeplanner.*;

/**
 *
 * @author pappavis
 */

public class clsLettertjes  {
        String CLASS_NAME = "clsLettertjes";

   public Vector AllAppObjects;
   public String ScrollText;
   public int newXPos1;         //'dit houd die startpositie van de tekst op de éérste frame.
  public int newYPos1;         //'dit houd die startpositie van de tekst op de éérste frame.

    int tileWidth, tileHeight;

    /** Creates a new instance of clsLettertjes */
    public clsLettertjes() {
    }
   
     // http://www.java-gaming.org/forums/index.php?topic=17434.0
   public void drawFrame (int col, int row, int xPos, int yPos )
    {
        int x = xPos;
        int y = yPos;

        // this could be done above but I prefer to show it this way as it makes the steps a little clearer.
       x -= col * tileWidth;
        y -= row * tileHeight;

        setclip( x, y, tileWidth, tileHeight);
        drawImage( image, x, y, Graphics.TOP|Graphics.LEFT);
    }    
}


My font bitmap:

[size=6pt]Credits: flameduck @blitzbasic.com[/size]

.
6  Java Game APIs & Engines / J2ME / old-school scrolltext using bitmapped fonts. How? on: 2007-09-21 16:05:18
I need a way to grab a squared area of a bitmap, to display it on screen.  My bitmappedfont is 320x288 big containing images each 25x25 (these are not the actuale sizes Wink ).

I need code/example on how to grab for example the 14th "character" from the bitmap, returning it as a ImageItem.  How to do such? Can anyone remember the old-skool horizontal scrolltexts "demo"/intro's on the ole' 8-bit computers (Amiga, Commodore64, Atari)? Such a scroller is my intention.

This is a short snippet of my code.
1  
2  
3  
4  
5  
6  
7  
      
               Sprite tmpSprite4 = new Sprite(objImages1.image.getImage(), 320, 288);
                LayerManager laagBeheer1 = new LayerManager();
                laagBeheer1.append(tmpSprite4);
                tmpSprite4.setPosition(5, 5);

                laagBeheer1.paint(this.graphics1, xpos, ypos);  //put the sprite in position


Actually my idea is to port some code of mine from BlitzMax to J2ME. This is the BlitzMax-verison of the scroller..

Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

Riven (20 views)
2014-07-29 18:09:19

Riven (13 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (31 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (42 views)
2014-07-24 01:59:36

Riven (42 views)
2014-07-23 21:16:32

Riven (28 views)
2014-07-23 21:07:15

Riven (29 views)
2014-07-23 20:56:16

ctomni231 (60 views)
2014-07-18 06:55:21
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!