Large Category

Home » Large Category

Random Access Files with Java

Random Access Files with Java Random Access Files (RAF) in Java are super easy to use. Use an RAF when you are doing more database-like operations vs document-like operations. With an RAF you can move to any location in the file based on the byte number.  Then read or write primitives and Strings. You can also read and write arrays of bytes. It would be easy enough to write a set of primitives associated with an object which is the object’s state, then reload and rebuild the object later. Six Examples So in this article, I will give you 6 examples of storing and reading – one, two and three dimensioned arrays of integers. The first 3 examples simply generate random numbers in arrays then write them to an RAF. They then read the whole file back displaying it at the console. The ...

Sprite Organizer 0.1 Alpha

Organizing Sprites, Tiles, Textures etc on Image Strips or Grids. This article is about a tool for organizing sprite or tile images into image grids or image strips. It’s useful for organizing game sprites, simulation sprites, textures or even CSS sprites used on web pages.  It has buffers which contain images. Images can be broken into cols and rows.  Cells or sprites are defined as so many pixels by so many pixels in size.  Saves and loads images.      Features Load and save single images or sprite sets. Load images into one of 10 buffers (more buffers in the next versions) Paste from one buffer into a grid or image strip.  Divide a blank image into cols or cols and rows. Sprite size is determined by the size of the grid in pixels and number of cols and rows. Copy, Paste,...

Simple 3D graphics using Java

Isometric or Orthogonal 3D views In this article, I demonstrate 3D Graphics showing you how to project a surface in 3D using 3 modes for drawing the surface. There is a left-hand mode, a center mode, and a right-hand mode. This same transformation math works for 3D polyhedron objects as well and you could use if for voxel type games. I show some effects you can use on the surface such as zoom, pan, skew etc. This is entirely wire frame. I do not remove hidden lines. I do not fill or texture map. And I do not rotate. I may do all this in future versions of this article. 90-degree rotation is very easy to do. Using basic trigonometry math more fine rotation is not difficult. The Iso3D class I did not have to put this code in its own class. As a matter of fact, in such a simple demo applicati...

Sound effects and Musical Notes.

Sound Effects and Musical Notes I will demo how to play a wave file or other sound files as effects. How to play musical notes. Later I will write on how to play music files simultaneously with sound effects.  There is a website that is like a YouTube for sound effects. freesound.org is a website where anyone can get an account to upload sound effects that they have recorded. So you too can record and contribute.  Sox Wikipedia and Sox Sourceforge is a command line sound conversion tool where you may convert most any format found on freesound.org to .wav for use in your Java software. Listen to my Podcast about 2D Game coding. Playing WAV Sound Effects I now show you how to play some sound effects. I have a small collection of wave files for a beaver trapping game. One of the files threw a...

Database: H2 (formerly HypersonicSQL)

H2 Database and Java When I began using Java years ago I heard of a database that was being coded entirely using Java. This was HypersonicSQL and you can still download it at Sourceforge. The author working on it decided it needed a rewrite and he began H2 database. First download H2 installer at H2 download.  Get the stable version 1.4.195 as the h2 jar file for the last version .196 gave a class not found exception on startup looking for the driver. And the tutorial can be found here H2 Tutorial.  Next look at your install and find the H2/bin folder. Here you find the jar file needed h2-some-version.jar i.e. h2-1.4.195.jar. Most if not all databases now create the database when you connect to it. All we need to do is make the JDBC connection and create a table, add some records with SQL ...

SQLite: JDBC and SQLite

SQLite and Java First, you must go to download page and get the binaries for either 32 or 64 bit, placing them in the system path. If you don’t know how to do that, google adding folders to the system path. There will be an SQLite.exe file. Run it as a command to verify that it is in the path and working. But for Java coding get the jar file at Jar file. A very good resource you will need is A good tutorial and Another tutorial. Working with Java and Files Tutorial Trail Serialize Java to XML H2 DB and Java Setup for simple example Download the SQLite jar file from BitBucket SQL downloads. Put it and the source below in the same folder. Set the classpath to include that jar file and the ‘.’ current folder or use -cp option with ‘sqlite-jdbc-3.21.0.jar;.’ when ...

  • 1
  • 2
  • 8