Pixel Font

The Partridge Family were neither partridges nor a family. Discuss.
User avatar
Nny
Posts: 3
Joined: October 22nd, 2016, 4:01 am

Pixel Font

Post by Nny » October 22nd, 2016, 5:09 am

I am sure there are MUCH better ways to do this, but based off what I've learned in the current series with the Chili Framework, this is what I came up with. I figure something similar was used back in the day on things like the 2600 when you saw badly done text drawn in the scenery of a game.

No special characters or punctuation for now, maybe later but I have a cold currently.


This part for Game.h

Code: Select all

	void Block(int x, int y, int r, int g, int b);
		void chA(int x, int y, int r, int g, int b);
		void chB(int x, int y, int r, int g, int b);
		void chC(int x, int y, int r, int g, int b);
		void chD(int x, int y, int r, int g, int b);
		void chE(int x, int y, int r, int g, int b);
		void chF(int x, int y, int r, int g, int b);
		void chG(int x, int y, int r, int g, int b);
		void chH(int x, int y, int r, int g, int b);
		void chI(int x, int y, int r, int g, int b);
		void chJ(int x, int y, int r, int g, int b);
		void chK(int x, int y, int r, int g, int b);
		void chL(int x, int y, int r, int g, int b);
		void chM(int x, int y, int r, int g, int b);
		void chN(int x, int y, int r, int g, int b);
		void chO(int x, int y, int r, int g, int b);
		void chP(int x, int y, int r, int g, int b);
		void chQ(int x, int y, int r, int g, int b);
		void chR(int x, int y, int r, int g, int b);
		void chS(int x, int y, int r, int g, int b);
		void chT(int x, int y, int r, int g, int b);
		void chU(int x, int y, int r, int g, int b);
		void chV(int x, int y, int r, int g, int b);
		void chW(int x, int y, int r, int g, int b);
		void chX(int x, int y, int r, int g, int b);
		void chY(int x, int y, int r, int g, int b);
		void chZ(int x, int y, int r, int g, int b);

This part for Game.cpp


// Each Letter is 5x6 "Pixel"s
// Each "Pixel" is actually a 3x3 cube with a 2 pixel gap between other "Pixels"
// Optimal tracking seems to be 35 with leading of 45 if you want things monospaced
// Monospaced text can look funky sometimes though, might need to tweak individual kerning if things look funky

Code: Select all

void Game::Block(int x, int y, int r, int g, int b)
{
	for (int xPos = x; xPos <= (x + 3); xPos++)
	{
		for (int yPos = y; yPos <= (y + 3); yPos++)
		{
			gfx.PutPixel(xPos, yPos, r, g, b);
		}
	}
} 

void Game::chA(int x, int y, int r, int g, int b)
{
	Block(x+10, y, r, g, b);

	Block(x+5, y+5, r, g, b);
	Block(x+15, y+5, r, g, b);

	Block(x, y+10, r, g, b);
	Block(x+20, y+10, r, g, b);

	Block(x, y+15, r, g, b);
	Block(x+5, y + 15, r, g, b);
	Block(x+10, y + 15, r, g, b);
	Block(x+15, y + 15, r, g, b);
	Block(x+20, y + 15, r, g, b);

	Block(x, y + 20, r, g, b);
	Block(x+20, y + 20, r, g, b);

	Block(x, y + 25, r, g, b);
	Block(x+20, y + 25, r, g, b);
}
void Game::chB(int x, int y, int r, int g, int b)
{
	Block(x, y, r, g, b);
	Block(x+5, y, r, g, b);
	Block(x+10, y, r, g, b);
	Block(x+15, y, r, g, b);

	Block(x, y+5, r, g, b);
	Block(x+20, y+5, r, g, b);

	Block(x, y+10, r, g, b);
	Block(x+5, y+10, r, g, b);
	Block(x+10, y+10, r, g, b);
	Block(x+15, y+10, r, g, b);

	Block(x, y+15, r, g, b);
	Block(x+20, y+15, r, g, b);

	Block(x, y+20, r, g, b);
	Block(x+20, y+20, r, g, b);

	Block(x, y+25, r, g, b);
	Block(x+5, y+25, r, g, b);
	Block(x+10, y+25, r, g, b);
	Block(x+15, y+25, r, g, b);
}
void Game::chC(int x, int y, int r, int g, int b)
{
	Block(x+5, y, r, g, b);
	Block(x+10, y, r, g, b);
	Block(x+15, y, r, g, b);

	Block(x, y+5, r, g, b);
	Block(x+20, y+5, r, g, b);

	Block(x, y+10, r, g, b);

	Block(x, y+15, r, g, b);

	Block(x, y+20, r, g, b);
	Block(x+20, y+20, r, g, b);

	Block(x+5, y+25, r, g, b);
	Block(x+10, y+25, r, g, b);
	Block(x+15, y+25, r, g, b);
}
void Game::chD(int x, int y, int r, int g, int b)
{
	Block(x, y, r, g, b);
	Block(x+5, y, r, g, b);
	Block(x+10, y, r, g, b);

	Block(x, y+5, r, g, b);
	Block(x+15, y+5, r, g, b);

	Block(x, y+10, r, g, b);
	Block(x+20, y+10, r, g, b);

	Block(x, y+15, r, g, b);
	Block(x+20, y+15, r, g, b);

	Block(x, y+20, r, g, b);
	Block(x+15, y+20, r, g, b);

	Block(x, y+25, r, g, b);
	Block(x+5, y+25, r, g, b);
	Block(x+10, y+25, r, g, b);
}
void Game::chE(int x, int y, int r, int g, int b)
{
	Block(x, y, r, g, b);
	Block(x+5, y, r, g, b);
	Block(x+10, y, r, g, b);
	Block(x+15, y, r, g, b);
	Block(x+20, y, r, g, b);

	Block(x, y+5, r, g, b);

	Block(x, y+10, r, g, b);
	Block(x+5, y+10, r, g, b);
	Block(x+10, y+10, r, g, b);

	Block(x, y+15, r, g, b);

	Block(x, y+20, r, g, b);

	Block(x, y+25, r, g, b);
	Block(x+5, y+25, r, g, b);
	Block(x+10, y+25, r, g, b);
	Block(x+15, y+25, r, g, b);
	Block(x+20, y+25, r, g, b);
}
void Game::chF(int x, int y, int r, int g, int b)
{
	Block(x, y, r, g, b);
	Block(x+5, y, r, g, b);
	Block(x+10, y, r, g, b);
	Block(x+15, y, r, g, b);
	Block(x+20, y, r, g, b);

	Block(x, y+5, r, g, b);

	Block(x, y+10, r, g, b);
	Block(x+5, y+10, r, g, b);
	Block(x+10, y+10, r, g, b);
			  
	Block(x, y+15, r, g, b);

	Block(x, y+20, r, g, b);

	Block(x, y+25, r, g, b);
}
void Game::chG(int x, int y, int r, int g, int b)
{
	Block(x+5, y, r, g, b);
	Block(x+10, y, r, g, b);
	Block(x+15, y, r, g, b);

	Block(x, y+5, r, g, b);
	Block(x+20, y+5, r, g, b);

	Block(x, y+10, r, g, b);

	Block(x, y+15, r, g, b);
	Block(x+10, y+15, r, g, b);
	Block(x+15, y+15, r, g, b);
	Block(x+20, y+15, r, g, b);

	Block(x, y+20, r, g, b);
	Block(x+20, y+20, r, g, b);

	Block(x+5, y+25, r, g, b);
	Block(x+10, y+25, r, g, b);
	Block(x+15, y+25, r, g, b);
}
void Game::chH(int x, int y, int r, int g, int b)
{
	Block(x, y, r, g, b);
	Block(x+20, y, r, g, b);

	Block(x, y+5, r, g, b);
	Block(x+20, y+5, r, g, b);

	Block(x, y+10, r, g, b);
	Block(x+5, y+10, r, g, b);
	Block(x+10, y+10, r, g, b);
	Block(x+15, y+10, r, g, b);
	Block(x+20, y+10, r, g, b);

	Block(x, y+15, r, g, b);
	Block(x+20, y+15, r, g, b);

	Block(x, y+20, r, g, b);
	Block(x+20, y+20, r, g, b);

	Block(x, y+25, r, g, b);
	Block(x+20, y+25, r, g, b);
}
void Game::chI(int x, int y, int r, int g, int b)
{
	Block(x, y, r, g, b);
	Block(x+5, y, r, g, b);
	Block(x+10, y, r, g, b);
	Block(x+15, y, r, g, b);
	Block(x+20, y, r, g, b);

	Block(x+10, y+5, r, g, b);
		   
	Block(x+10, y+10, r, g, b);
		   
	Block(x+10, y+15, r, g, b);
		   
	Block(x+10, y+20, r, g, b);

	Block(x, y+25, r, g, b);
	Block(x+5, y+25, r, g, b);
	Block(x+10, y+25, r, g, b);
	Block(x+15, y+25, r, g, b);
	Block(x+20, y+25, r, g, b);
}
void Game::chJ(int x, int y, int r, int g, int b)
{
	Block(x, y, r, g, b);
	Block(x+5, y, r, g, b);
	Block(x+10, y, r, g, b);
	Block(x+15, y, r, g, b);
	Block(x+20, y, r, g, b);

	Block(x+10, y+5, r, g, b);

	Block(x+10, y+10, r, g, b);

	Block(x+10, y+15, r, g, b);

	Block(x, y+20, r, g, b);
	Block(x+10, y+20, r, g, b);

	Block(x+5, y+25, r, g, b);
	Block(x+10, y+25, r, g, b);
}
void Game::chK(int x, int y, int r, int g, int b)
{
	Block(x, y, r, g, b);
	Block(x+20, y, r, g, b);

	Block(x, y+5, r, g, b);
	Block(x+15, y+5, r, g, b);

	Block(x, y+10, r, g, b);
	Block(x+5, y+10, r, g, b);
	Block(x+10, y+10, r, g, b);

	Block(x, y+15, r, g, b);
	Block(x+10, y+15, r, g, b);

	Block(x, y+20, r, g, b);
	Block(x+15, y+20, r, g, b);

	Block(x, y+25, r, g, b);
	Block(x+20, y+25, r, g, b);
}
void Game::chL(int x, int y, int r, int g, int b)
{
	Block(x, y, r, g, b);

	Block(x, y+5, r, g, b);

	Block(x, y+10, r, g, b);

	Block(x, y+15, r, g, b);

	Block(x, y+20, r, g, b);

	Block(x, y+25, r, g, b);
	Block(x+5, y+25, r, g, b);
	Block(x+10, y+25, r, g, b);
	Block(x+15, y+25, r, g, b);
	Block(x+20, y+25, r, g, b);
}
void Game::chM(int x, int y, int r, int g, int b)
{
	Block(x, y, r, g, b);
	Block(x+20, y, r, g, b);

	Block(x, y+5, r, g, b);
	Block(x+5, y+5, r, g, b);
	Block(x+15, y+5, r, g, b);
	Block(x+20, y+5, r, g, b);

	Block(x, y+10, r, g, b);
	Block(x+10, y+10, r, g, b);
	Block(x+20, y+10, r, g, b);

	Block(x, y+15, r, g, b);
	Block(x+10, y+15, r, g, b);
	Block(x+20, y+15, r, g, b);

	Block(x, y+20, r, g, b);
	Block(x+20, y+20, r, g, b);

	Block(x, y+25, r, g, b);
	Block(x+20, y+25, r, g, b);
}
void Game::chN(int x, int y, int r, int g, int b)
{
	Block(x, y, r, g, b);
	Block(x+20, y, r, g, b);

	Block(x, y+5, r, g, b);
	Block(x+5, y+5, r, g, b);
	Block(x+20, y+5, r, g, b);

	Block(x, y+10, r, g, b);
	Block(x+10, y+10, r, g, b);
	Block(x+20, y+10, r, g, b);

	Block(x, y+15, r, g, b);
	Block(x+15, y+15, r, g, b);
	Block(x+20, y+15, r, g, b);

	Block(x, y+20, r, g, b);
	Block(x+20, y+20, r, g, b);

	Block(x, y+25, r, g, b);
	Block(x+20, y+25, r, g, b);
}
void Game::chO(int x, int y, int r, int g, int b)
{
	Block(x+5, y, r, g, b);
	Block(x+10, y, r, g, b);
	Block(x+15, y, r, g, b);

	Block(x, y+5, r, g, b);
	Block(x+20, y+5, r, g, b);

	Block(x, y+10, r, g, b);
	Block(x+20, y+10, r, g, b);

	Block(x, y+15, r, g, b);
	Block(x+20, y+15, r, g, b);

	Block(x, y+20, r, g, b);
	Block(x+20, y+20, r, g, b);

	Block(x+5, y+25, r, g, b);
	Block(x+10, y+25, r, g, b);
	Block(x+15, y+25, r, g, b);
}
void Game::chP(int x, int y, int r, int g, int b)
{
	Block(x, y, r, g, b);
	Block(x+5, y, r, g, b);
	Block(x+10, y, r, g, b);
	Block(x+15, y, r, g, b);

	Block(x, y+5, r, g, b);
	Block(x+20, y+5, r, g, b);

	Block(x, y+10, r, g, b);
	Block(x+5, y+10, r, g, b);
	Block(x+10, y+10, r, g, b);
	Block(x+15, y+10, r, g, b);

	Block(x, y+15, r, g, b);

	Block(x, y+20, r, g, b);

	Block(x, y+25, r, g, b);
}
void Game::chQ(int x, int y, int r, int g, int b)
{
	Block(x+5, y, r, g, b);
	Block(x+10, y, r, g, b);
	Block(x+15, y, r, g, b);

	Block(x, y+5, r, g, b);
	Block(x+20, y+5, r, g, b);

	Block(x, y+10, r, g, b);
	Block(x+20, y+10, r, g, b);

	Block(x, y+15, r, g, b);
	Block(x+10, y+15, r, g, b);
	Block(x+20, y+15, r, g, b);

	Block(x, y+20, r, g, b);
	Block(x+15, y+20, r, g, b);

	Block(x+5, y+25, r, g, b);
	Block(x+10, y+25, r, g, b);
	Block(x+20, y+25, r, g, b);
}
void Game::chR(int x, int y, int r, int g, int b)
{
	Block(x, y, r, g, b);
	Block(x+5, y, r, g, b);
	Block(x+10, y, r, g, b);
	Block(x+15, y, r, g, b);

	Block(x, y+5, r, g, b);
	Block(x+20, y+5, r, g, b);

	Block(x, y+10, r, g, b);
	Block(x+5, y+10, r, g, b);
	Block(x+10, y+10, r, g, b);
	Block(x+15, y+10, r, g, b);

	Block(x, y+15, r, g, b);
	Block(x+20, y+15, r, g, b);

	Block(x, y+20, r, g, b);
	Block(x+20, y+20, r, g, b);

	Block(x, y+25, r, g, b);
	Block(x+20, y+25, r, g, b);
}
void Game::chS(int x, int y, int r, int g, int b)
{
	Block(x+5, y, r, g, b);
	Block(x+10, y, r, g, b);
	Block(x+15, y, r, g, b);
	Block(x+20, y, r, g, b);

	Block(x, y+5, r, g, b);

	Block(x+5, y+10, r, g, b);
	Block(x+10, y+10, r, g, b);
	Block(x+15, y+10, r, g, b);

	Block(x+20, y+15, r, g, b);

	Block(x+20, y+20, r, g, b);

	Block(x, y+25, r, g, b);
	Block(x+5, y+25, r, g, b);
	Block(x+10, y+25, r, g, b);
	Block(x+15, y+25, r, g, b);
}
void Game::chT(int x, int y, int r, int g, int b)
{
	Block(x, y, r, g, b);
	Block(x+5, y, r, g, b);
	Block(x+10, y, r, g, b);
	Block(x+15, y, r, g, b);
	Block(x+20, y, r, g, b);

	Block(x+10, y+5, r, g, b);

	Block(x+10, y+10, r, g, b);

	Block(x+10, y+15, r, g, b);

	Block(x+10, y+20, r, g, b);

	Block(x+10, y+25, r, g, b);
}
void Game::chU(int x, int y, int r, int g, int b)
{
	Block(x, y, r, g, b);
	Block(x+20, y, r, g, b);

	Block(x, y+5, r, g, b);
	Block(x+20, y+5, r, g, b);

	Block(x, y+10, r, g, b);
	Block(x+20, y+10, r, g, b);

	Block(x, y+15, r, g, b);
	Block(x+20, y+15, r, g, b);

	Block(x, y+20, r, g, b);
	Block(x+20, y+20, r, g, b);

	Block(x+5, y+25, r, g, b);
	Block(x+10, y+25, r, g, b);
	Block(x+15, y+25, r, g, b);
}
void Game::chV(int x, int y, int r, int g, int b)
{
	Block(x, y, r, g, b);
	Block(x+20, y, r, g, b);

	Block(x, y+5, r, g, b);
	Block(x+20, y+5, r, g, b);

	Block(x, y+10, r, g, b);
	Block(x+20, y+10, r, g, b);

	Block(x+5, y+15, r, g, b);
	Block(x+15, y+15, r, g, b);

	Block(x+5, y+20, r, g, b);
	Block(x+15, y+20, r, g, b);

	Block(x+10, y+25, r, g, b);
}
void Game::chW(int x, int y, int r, int g, int b)
{
	Block(x, y, r, g, b);
	Block(x+20, y, r, g, b);

	Block(x, y+5, r, g, b);
	Block(x+20, y+5, r, g, b);

	Block(x, y+10, r, g, b);
	Block(x+20, y+10, r, g, b);

	Block(x, y+15, r, g, b);
	Block(x+10, y+15, r, g, b);
	Block(x+20, y+15, r, g, b);

	Block(x, y+20, r, g, b);
	Block(x+10, y+20, r, g, b);
	Block(x+20, y+20, r, g, b);

	Block(x+5, y+25, r, g, b);
	Block(x+15, y+25, r, g, b);
}
void Game::chX(int x, int y, int r, int g, int b)
{
	Block(x, y, r, g, b);
	Block(x+20, y, r, g, b);

	Block(x+5, y+5, r, g, b);
	Block(x+15, y+5, r, g, b);

	Block(x+10, y+10, r, g, b);

	Block(x+10, y+15, r, g, b);

	Block(x+5, y+20, r, g, b);
	Block(x+15, y+20, r, g, b);

	Block(x, y+25, r, g, b);
	Block(x+20, y+25, r, g, b);
}
void Game::chY(int x, int y, int r, int g, int b)
{
	Block(x, y, r, g, b);
	Block(x+20, y, r, g, b);

	Block(x, y+5, r, g, b);
	Block(x+20, y+5, r, g, b);

	Block(x+5, y+10, r, g, b);
	Block(x+15, y+10, r, g, b);

	Block(x+10, y+15, r, g, b);

	Block(x+10, y+20, r, g, b);

	Block(x+10, y+25, r, g, b);
}
void Game::chZ(int x, int y, int r, int g, int b)
{
	Block(x, y, r, g, b);
	Block(x+5, y, r, g, b);
	Block(x+10, y, r, g, b);
	Block(x+15, y, r, g, b);
	Block(x+20, y, r, g, b);

	Block(x+20, y+5, r, g, b);

	Block(x+15, y+10, r, g, b);

	Block(x+10, y+15, r, g, b);

	Block(x+5, y+20, r, g, b);

	Block(x, y+25, r, g, b);
	Block(x+5, y+25, r, g, b);
	Block(x+10, y+25, r, g, b);
	Block(x+15, y+25, r, g, b);
	Block(x+20, y+25, r, g, b);
}
Image

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Pixel Font

Post by chili » October 22nd, 2016, 5:19 am

Hmm, I would have just done it like a function full of putpixels, one for each character. I like this solution. If I do an update video I'll try and remember to pimp it out :D
Chili

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Pixel Font

Post by albinopapa » October 22nd, 2016, 4:31 pm

Did you use graph paper to determine the pixel/block locations? Or, maybe just zoomed in on some text in a paint program?

I like the effect, gives it an old computer screen look or a marquee sign.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
Nny
Posts: 3
Joined: October 22nd, 2016, 4:01 am

Re: Pixel Font

Post by Nny » October 22nd, 2016, 7:35 pm

chili wrote:Hmm, I would have just done it like a function full of putpixels, one for each character. I like this solution. If I do an update video I'll try and remember to pimp it out :D
^_^
albinopapa wrote:Did you use graph paper to determine the pixel/block locations? Or, maybe just zoomed in on some text in a paint program?

I like the effect, gives it an old computer screen look or a marquee sign.
Graph Paper all the way. Made it easier to just look at and know what x's and y's I needed to +whatever to without a lot of back and forth.

User avatar
Alacaster
Posts: 81
Joined: October 16th, 2016, 5:08 pm
Location: Spokane, WA

Re: Pixel Font

Post by Alacaster » October 23rd, 2016, 11:21 pm

Dude, this is so awesome.
You can't be betrayed if you don't have any friends.
Why live? Cause why not.

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Pixel Font

Post by chili » October 24th, 2016, 3:57 am

Now you need to make function that takes a string and a position and renders the string at that position on the screen :P
Chili

reductor
Posts: 49
Joined: October 24th, 2016, 12:23 pm

Re: Pixel Font

Post by reductor » October 24th, 2016, 9:24 pm

One approach you could take to break this down into something more readable would be to create a function that will output a collection of pixels (based on a mask) to the screen.

Code: Select all

template<std::size_t Width, std::size_t Height>
using PixelMap = std::array<std::array<Width, bool>, Height>;

template<std::size_t Width, std::size_t Height>
void DrawPixels( int x, int y, const PixelMap<Width,Height> & pixels );
Once you have this function you can then start constructing arrays of pixels (Including reading them from disk). Instead of an std::array inside of an std::array here you could use a string then have a char mark if a pixel should be output.

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Pixel Font

Post by chili » October 25th, 2016, 12:37 am

Yes, this approach (but not with static arrays of course, and not using templates) will be taken later in the series, after we have learned about, pointers, memory allocation, file IO, etc. Nny's approach here is cool because it is achieved with a minimum of language features.

The final goal is to use GDI+ or DirectWrite to handle the font loading / text drawing for us.
Chili

User avatar
krautersuppe
Posts: 91
Joined: September 14th, 2015, 10:58 pm
Location: Istanbul

Re: Pixel Font

Post by krautersuppe » April 22nd, 2017, 2:39 am

Nny wrote:
No special characters or punctuation for now, maybe later but I have a cold currently.
I made numbers and punctuation:
in Game.h:

Code: Select all

void ch0(int x, int y, int r, int g, int b);
void ch1(int x, int y, int r, int g, int b);
void ch2(int x, int y, int r, int g, int b);
void ch3(int x, int y, int r, int g, int b);
void ch4(int x, int y, int r, int g, int b);
void ch5(int x, int y, int r, int g, int b);
void ch6(int x, int y, int r, int g, int b);
void ch7(int x, int y, int r, int g, int b);
void ch8(int x, int y, int r, int g, int b);
void ch9(int x, int y, int r, int g, int b);

void chPoint(int x, int y, int r, int g, int b);
void chApostrophe(int x, int y, int r, int g, int b);
void chExMark(int x, int y, int r, int g, int b);
void chQMark(int x, int y, int r, int g, int b);
void chDash(int x, int y, int r, int g, int b);
in Game.cpp:

Code: Select all

void Game::ch0(int x, int y, int r, int g, int b)
{
	Block(x + 5, y, r, g, b);
	Block(x + 10, y, r, g, b);
	Block(x + 15, y, r, g, b);

	Block(x, y + 5, r, g, b);
	Block(x + 15, y + 5, r, g, b);
	Block(x + 20, y + 5, r, g, b);

	Block(x, y + 10, r, g, b);
	Block(x + 10, y + 10, r, g, b);
	Block(x + 20, y + 10, r, g, b);

	Block(x, y + 15, r, g, b);
	Block(x + 10, y + 15, r, g, b);
	Block(x + 20, y + 15, r, g, b);

	Block(x, y + 20, r, g, b);
	Block(x + 5, y + 20, r, g, b);
	Block(x + 20, y + 20, r, g, b);

	Block(x + 5, y + 25, r, g, b);
	Block(x + 10, y + 25, r, g, b);
	Block(x + 15, y + 25, r, g, b);
}

void Game::ch1(int x, int y, int r, int g, int b)
{
	Block(x + 10, y, r, g, b);

	Block(x + 5, y + 5, r, g, b);
	Block(x + 10, y + 5, r, g, b);

	Block(x, y + 10, r, g, b);
	Block(x + 10, y + 10, r, g, b);

	Block(x + 10, y + 15, r, g, b);

	Block(x + 10, y + 20, r, g, b);

	Block(x, y + 25, r, g, b);
	Block(x + 5, y + 25, r, g, b);
	Block(x + 10, y + 25, r, g, b);
	Block(x + 15, y + 25, r, g, b);
	Block(x + 20, y + 25, r, g, b);
}

void Game::ch2(int x, int y, int r, int g, int b)
{
	Block(x + 5, y, r, g, b);
	Block(x + 10, y, r, g, b);
	Block(x + 15, y, r, g, b);

	Block(x, y + 5, r, g, b);
	Block(x + 20, y + 5, r, g, b);

	Block(x + 20, y + 10, r, g, b);

	Block(x + 5, y + 15, r, g, b);
	Block(x + 10, y + 15, r, g, b);
	Block(x + 15, y + 15, r, g, b);

	Block(x, y + 20, r, g, b);

	Block(x, y + 25, r, g, b);
	Block(x + 5, y + 25, r, g, b);
	Block(x + 10, y + 25, r, g, b);
	Block(x + 15, y + 25, r, g, b);
	Block(x + 20, y + 25, r, g, b);
}

void Game::ch3(int x, int y, int r, int g, int b)
{
	Block(x, y, r, g, b);
	Block(x + 5, y, r, g, b);
	Block(x + 10, y, r, g, b);
	Block(x + 15, y, r, g, b);

	Block(x + 20, y + 5, r, g, b);

	Block(x + 20, y + 10, r, g, b);

	Block(x, y + 15, r, g, b);
	Block(x + 5, y + 15, r, g, b);
	Block(x + 10, y + 15, r, g, b);
	Block(x + 15, y + 15, r, g, b);

	Block(x + 20, y + 20, r, g, b);

	Block(x, y + 25, r, g, b);
	Block(x + 5, y + 25, r, g, b);
	Block(x + 10, y + 25, r, g, b);
	Block(x + 15, y + 25, r, g, b);
	Block(x + 20, y + 25, r, g, b);
}

void Game::ch4(int x, int y, int r, int g, int b)
{
	Block(x + 15, y, r, g, b);

	Block(x + 10, y + 5, r, g, b);
	Block(x + 15, y + 5, r, g, b);

	Block(x + 5, y + 10, r, g, b);
	Block(x + 15, y + 10, r, g, b);

	Block(x, y + 15, r, g, b);
	Block(x + 15, y + 15, r, g, b);

	Block(x, y + 20, r, g, b);
	Block(x + 5, y + 20, r, g, b);
	Block(x + 10, y + 20, r, g, b);
	Block(x + 15, y + 20, r, g, b);
	Block(x + 20, y + 20, r, g, b);

	Block(x + 15, y + 25, r, g, b);
}

void Game::ch5(int x, int y, int r, int g, int b)
{
	Block(x, y, r, g, b);
	Block(x + 5, y, r, g, b);
	Block(x + 10, y, r, g, b);
	Block(x + 15, y, r, g, b);
	Block(x + 20, y, r, g, b);

	Block(x, y + 5, r, g, b);

	Block(x, y + 10, r, g, b);
	Block(x + 5, y + 10, r, g, b);
	Block(x + 10, y + 10, r, g, b);
	Block(x + 15, y + 10, r, g, b);


	Block(x + 20, y + 15, r, g, b);

	Block(x + 20, y + 20, r, g, b);

	Block(x, y + 25, r, g, b);
	Block(x + 5, y + 25, r, g, b);
	Block(x + 10, y + 25, r, g, b);
	Block(x + 15, y + 25, r, g, b);
}

void Game::ch6(int x, int y, int r, int g, int b)
{
	Block(x + 10, y, r, g, b);
	Block(x + 15, y, r, g, b);
	Block(x + 20, y, r, g, b);

	Block(x + 5, y + 5, r, g, b);

	Block(x, y + 10, r, g, b);

	Block(x, y + 15, r, g, b);
	Block(x + 5, y + 15, r, g, b);
	Block(x + 10, y + 15, r, g, b);
	Block(x + 15, y + 15, r, g, b);

	Block(x, y + 20, r, g, b);
	Block(x + 20, y + 20, r, g, b);

	Block(x + 5, y + 25, r, g, b);
	Block(x + 10, y + 25, r, g, b);
	Block(x + 15, y + 25, r, g, b);
}

void Game::ch7(int x, int y, int r, int g, int b)
{
	Block(x, y, r, g, b);
	Block(x + 5, y, r, g, b);
	Block(x + 10, y, r, g, b);
	Block(x + 15, y, r, g, b);
	Block(x + 20, y, r, g, b);

	Block(x + 20, y + 5, r, g, b);

	Block(x + 15, y + 10, r, g, b);

	Block(x + 10, y + 15, r, g, b);

	Block(x + 5, y + 20, r, g, b);

	Block(x, y + 25, r, g, b);
}

void Game::ch8(int x, int y, int r, int g, int b)
{
	Block(x + 5, y, r, g, b);
	Block(x + 10, y, r, g, b);
	Block(x + 15, y, r, g, b);

	Block(x, y + 5, r, g, b);
	Block(x + 20, y + 5, r, g, b);

	Block(x + 5, y + 10, r, g, b);
	Block(x + 10, y + 10, r, g, b);
	Block(x + 15, y + 10, r, g, b);

	Block(x, y + 15, r, g, b);
	Block(x + 20, y + 15, r, g, b);

	Block(x, y + 20, r, g, b);
	Block(x + 20, y + 20, r, g, b);

	Block(x + 5, y + 25, r, g, b);
	Block(x + 10, y + 25, r, g, b);
	Block(x + 15, y + 25, r, g, b);
}

void Game::ch9(int x, int y, int r, int g, int b)
{
	Block(x + 5, y, r, g, b);
	Block(x + 10, y, r, g, b);
	Block(x + 15, y, r, g, b);

	Block(x, y + 5, r, g, b);
	Block(x + 20, y + 5, r, g, b);

	Block(x + 5, y + 10, r, g, b);
	Block(x + 10, y + 10, r, g, b);
	Block(x + 15, y + 10, r, g, b);
	Block(x + 20, y + 10, r, g, b);

	Block(x + 20, y + 15, r, g, b);

	Block(x + 15, y + 20, r, g, b);

	Block(x + 10, y + 25, r, g, b);
}


void Game::chPoint(int x, int y, int r, int g, int b)
{
	Block(x, y + 25, r, g, b);
}

void Game::chApostrophe(int x, int y, int r, int g, int b)
{
	Block(x, y, r, g, b);

	Block(x, y + 5, r, g, b);
}

void Game::chExMark(int x, int y, int r, int g, int b)
{
	Block(x, y, r, g, b);

	Block(x, y + 5, r, g, b);

	Block(x, y + 10, r, g, b);

	Block(x, y + 15, r, g, b);

	Block(x, y + 25, r, g, b);
}

void Game::chDash(int x, int y, int r, int g, int b)
{
	Block(x, y + 10, r, g, b);
	Block(x + 5, y + 10, r, g, b);
	Block(x + 10, y + 10, r, g, b);
}

void Game::chQMark(int x, int y, int r, int g, int b)
{
	Block(x + 5, y, r, g, b);
	Block(x + 10, y, r, g, b);
	Block(x + 15, y, r, g, b);

	Block(x, y + 5, r, g, b);
	Block(x + 20, y + 5, r, g, b);

	Block(x + 15, y + 10, r, g, b);

	Block(x + 10, y + 15, r, g, b);

	Block(x + 10, y + 25, r, g, b);
}
Numbers.png
Numbers.png (1.15 KiB) Viewed 3749 times
DSU
Discord: dsu1, GitHub: https://github.com/DSpUz

User avatar
DEM0N194
Posts: 28
Joined: April 15th, 2017, 4:14 pm
Location: Slovakia
Contact:

Re: Pixel Font

Post by DEM0N194 » April 30th, 2017, 8:57 pm

First of all, thank you Nny and krautersuppe for making this.
This is something I wanted to do for a very long time, but never got to it... cuz I'm a lazy mofo.
So thx for making this really.

So .. I created some functionality around this...
a Text class where you can input a string and set the position, color, etc. and it draws every character for you.
I also created a Counter class, which behaves like an int except it draws itself to the screen.
(I can finally add a score counter to my pong game yay :D)

Here it is if you want to check it out: https://github.com/DEM0N194/PixelFont

Once again thx for sharing this with us :)

Post Reply