This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Tiin57's profile picture

Creating a shell

Started by Tiin57, 27 March 2013 - 10:49 PM
Tiin57 #1
Posted 27 March 2013 - 11:49 PM
I would like to know what methods you use (concepts and such) to create a shell. I'm trying to create one based on a BufferedImage and Graphics2D in Java, but it's tough to conceptualize.
Edit: To clarify, this is not running in CC; it's pure Java.
Mads #2
Posted 28 March 2013 - 12:41 AM
You could set up a tilemap like this:


package idfk;

public class Shell_CharMap
{
	public int charWidth, charHeight;
	public Shell_Char chars[50][19] = new Shell_Char[50][19];

	public void draw(Graphics2D g, int drawX, int drawY)
	{
		for(int x = 0; x < 50; x++)
		{
			for(int y = 0; y < 19; y++)
			{
				chars[x][y].draw(g, drawX + x * charWidth, drawY + y * charHeight);
			}
		}
	}

	class Shell_Char
	{
		private char content = ' ';

		public void draw(Graphics2D g, int x, int y)
		{
			// Draw some shit
		}

		// Set content and reload image
		public void setContent(char c)
		{
			content = c;
		}

		public char getContent()
		{
			return content;
		}
	}
}
(beware of syntax errors, haven't used Java for a while)

And then implement some form of UI.