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
| 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); } } } |
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.