Skip to content

Commit

Permalink
Added a new font, hyperspace.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Simo committed Nov 16, 2014
1 parent 597f622 commit e5fd060
Show file tree
Hide file tree
Showing 12 changed files with 111 additions and 54 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ ADD_EXECUTABLE(
src/EnemyShip.cpp
src/BitmapFont.cpp
src/Texture.cpp
src/vector_battle_regular_20.cxx
src/BitmapFontXMLParser.cxx
)

TARGET_LINK_LIBRARIES(
Expand Down
35 changes: 0 additions & 35 deletions fonts/Parse.cpp

This file was deleted.

8 changes: 0 additions & 8 deletions fonts/README.txt

This file was deleted.

File renamed without changes.
Binary file added fonts/hyperspace.ttf
Binary file not shown.
Binary file added fonts/hyperspace_bold_65.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
98 changes: 98 additions & 0 deletions fonts/hyperspace_bold_65.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="utf-8"?>
<Font family="Hyperspace" size="65" style="Bold" height="111">
<Char width="55" rect="1 68 0 0" code=" " offset="0 93"/>
<Char width="55" rect="2 1 5 68" code="!" offset="21 26"/>
<Char width="55" rect="8 1 26 11" code="&quot;" offset="8 26"/>
<Char width="55" rect="35 1 46 68" code="#" offset="0 26"/>
<Char width="55" rect="82 1 47 68" code="$" offset="0 26"/>
<Char width="55" rect="130 1 47 68" code="%" offset="0 26"/>
<Char width="55" rect="178 1 47 68" code="&amp;" offset="0 26"/>
<Char width="55" rect="226 1 9 11" code="'" offset="17 26"/>
<Char width="55" rect="236 1 27 68" code="(" offset="10 26"/>
<Char width="55" rect="264 1 27 68" code=")" offset="10 26"/>
<Char width="55" rect="292 1 46 68" code="*" offset="0 26"/>
<Char width="55" rect="339 1 46 68" code="+" offset="0 26"/>
<Char width="55" rect="386 62 9 11" code="," offset="17 87"/>
<Char width="55" rect="396 33 46 4" code="-" offset="0 58"/>
<Char width="55" rect="443 63 5 6" code="." offset="21 88"/>
<Char width="55" rect="449 1 47 68" code="/" offset="0 26"/>
<Char width="55" rect="497 1 47 68" code="0" offset="0 26"/>
<Char width="55" rect="545 1 5 68" code="1" offset="21 26"/>
<Char width="55" rect="551 1 47 68" code="2" offset="0 26"/>
<Char width="55" rect="599 1 47 68" code="3" offset="0 26"/>
<Char width="55" rect="647 1 47 68" code="4" offset="0 26"/>
<Char width="55" rect="695 1 47 68" code="5" offset="0 26"/>
<Char width="55" rect="743 1 47 68" code="6" offset="0 26"/>
<Char width="55" rect="791 1 47 68" code="7" offset="0 26"/>
<Char width="55" rect="839 1 47 68" code="8" offset="0 26"/>
<Char width="55" rect="887 1 47 68" code="9" offset="0 26"/>
<Char width="55" rect="935 32 5 37" code=":" offset="21 57"/>
<Char width="55" rect="941 31 9 42" code=";" offset="17 56"/>
<Char width="55" rect="951 1 47 68" code="&lt;" offset="0 26"/>
<Char width="55" rect="1 95 46 26" code="=" offset="0 47"/>
<Char width="55" rect="48 74 47 68" code=">" offset="0 26"/>
<Char width="55" rect="96 74 47 68" code="?" offset="0 26"/>
<Char width="55" rect="144 74 47 68" code="@" offset="0 26"/>
<Char width="55" rect="192 74 47 68" code="A" offset="0 26"/>
<Char width="55" rect="240 74 47 68" code="B" offset="0 26"/>
<Char width="55" rect="288 74 47 68" code="C" offset="0 26"/>
<Char width="55" rect="336 74 47 68" code="D" offset="0 26"/>
<Char width="55" rect="384 74 47 68" code="E" offset="0 26"/>
<Char width="55" rect="432 74 47 68" code="F" offset="0 26"/>
<Char width="55" rect="480 74 47 68" code="G" offset="0 26"/>
<Char width="55" rect="528 74 47 68" code="H" offset="0 26"/>
<Char width="55" rect="576 74 46 68" code="I" offset="0 26"/>
<Char width="55" rect="623 74 47 68" code="J" offset="0 26"/>
<Char width="55" rect="671 74 47 68" code="K" offset="0 26"/>
<Char width="55" rect="719 74 47 68" code="L" offset="0 26"/>
<Char width="55" rect="767 74 47 68" code="M" offset="0 26"/>
<Char width="55" rect="815 74 47 68" code="N" offset="0 26"/>
<Char width="55" rect="863 74 47 68" code="O" offset="0 26"/>
<Char width="55" rect="911 74 47 68" code="P" offset="0 26"/>
<Char width="55" rect="959 74 47 68" code="Q" offset="0 26"/>
<Char width="55" rect="1 170 47 68" code="R" offset="0 26"/>
<Char width="55" rect="49 170 47 68" code="S" offset="0 26"/>
<Char width="55" rect="97 170 46 68" code="T" offset="0 26"/>
<Char width="55" rect="144 170 47 68" code="U" offset="0 26"/>
<Char width="55" rect="192 170 46 68" code="V" offset="0 26"/>
<Char width="55" rect="239 170 47 68" code="W" offset="0 26"/>
<Char width="55" rect="287 170 46 68" code="X" offset="0 26"/>
<Char width="55" rect="334 170 46 68" code="Y" offset="0 26"/>
<Char width="55" rect="381 170 46 68" code="Z" offset="0 26"/>
<Char width="55" rect="428 170 25 68" code="[" offset="11 26"/>
<Char width="55" rect="454 170 47 68" code="\" offset="0 26"/>
<Char width="55" rect="502 170 25 68" code="]" offset="11 26"/>
<Char width="55" rect="528 143 46 24" code="^" offset="0 -1"/>
<Char width="55" rect="575 246 46 4" code="_" offset="0 102"/>
<Char width="55" rect="622 143 27 24" code="`" offset="10 -1"/>
<Char width="55" rect="650 170 47 68" code="a" offset="0 26"/>
<Char width="55" rect="698 170 47 68" code="b" offset="0 26"/>
<Char width="55" rect="746 170 47 68" code="c" offset="0 26"/>
<Char width="55" rect="794 170 47 68" code="d" offset="0 26"/>
<Char width="55" rect="842 170 47 68" code="e" offset="0 26"/>
<Char width="55" rect="890 170 47 68" code="f" offset="0 26"/>
<Char width="55" rect="938 170 47 68" code="g" offset="0 26"/>
<Char width="55" rect="1 262 47 68" code="h" offset="0 26"/>
<Char width="55" rect="49 262 46 68" code="i" offset="0 26"/>
<Char width="55" rect="96 262 47 68" code="j" offset="0 26"/>
<Char width="55" rect="144 262 47 68" code="k" offset="0 26"/>
<Char width="55" rect="192 262 47 68" code="l" offset="0 26"/>
<Char width="55" rect="240 262 47 68" code="m" offset="0 26"/>
<Char width="55" rect="288 262 47 68" code="n" offset="0 26"/>
<Char width="55" rect="336 262 47 68" code="o" offset="0 26"/>
<Char width="55" rect="384 262 47 68" code="p" offset="0 26"/>
<Char width="55" rect="432 262 47 68" code="q" offset="0 26"/>
<Char width="55" rect="480 262 47 68" code="r" offset="0 26"/>
<Char width="55" rect="528 262 47 68" code="s" offset="0 26"/>
<Char width="55" rect="576 262 46 68" code="t" offset="0 26"/>
<Char width="55" rect="623 262 47 68" code="u" offset="0 26"/>
<Char width="55" rect="671 262 46 68" code="v" offset="0 26"/>
<Char width="55" rect="718 262 47 68" code="w" offset="0 26"/>
<Char width="55" rect="766 262 46 68" code="x" offset="0 26"/>
<Char width="55" rect="813 262 46 68" code="y" offset="0 26"/>
<Char width="55" rect="860 262 46 68" code="z" offset="0 26"/>
<Char width="55" rect="907 262 47 68" code="{" offset="0 26"/>
<Char width="55" rect="955 251 5 90" code="|" offset="21 15"/>
<Char width="55" rect="961 262 47 68" code="}" offset="0 26"/>
<Char width="55" rect="1 342 47 24" code="~" offset="0 -1"/>
</Font>
File renamed without changes.
2 changes: 1 addition & 1 deletion src/BitmapFontXMLParser.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

#include <xsd/cxx/pre.hxx>

#include "FontParser.hxx"
#include "BitmapFontXMLParser.hxx"

// Font
//
Expand Down
1 change: 0 additions & 1 deletion src/Drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ void DrawText(
}

BitmapFontGlyph glyph = font->GetGlyph(text[i]);
std::cout << glyph.x << " " << glyph.y << std::endl;
Rect clip;
clip.x = glyph.x;
clip.y = glyph.y;
Expand Down
18 changes: 10 additions & 8 deletions src/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace asteroids
{
m_width = width;
m_height = height;
m_state = GameState::PLAYING;
m_state = GameState::MENU;
m_playerRespawnWait = WORLD_PLAYER_RESPAWN_WAIT;
m_enemyShipRespawnWait = WORLD_ENEMYSHIP_RESPAWN_WAIT;

Expand Down Expand Up @@ -48,8 +48,8 @@ namespace asteroids
if(m_bitmapFont == nullptr)
{
m_bitmapFont = new BitmapFont();
m_bitmapFont->LoadBitmap("/home/pavelsimo/workspace/Games_Cpp/Asteroids/fonts/vector_battle_regular_20.png");
m_bitmapFont->LoadGlyphsFromXML("/home/pavelsimo/workspace/Games_Cpp/Asteroids/fonts/vector_battle_regular_20.xml");
m_bitmapFont->LoadBitmap("/home/pavelsimo/workspace/Games_Cpp/Asteroids/fonts/hyperspace_bold_65.png");
m_bitmapFont->LoadGlyphsFromXML("/home/pavelsimo/workspace/Games_Cpp/Asteroids/fonts/hyperspace_bold_65.xml");
return true;
}
return false;
Expand All @@ -66,12 +66,11 @@ namespace asteroids

void World::Render()
{

DrawText(m_width * 0.5f - 200, m_height * 0.5f, "Will you marry me xiong!", m_bitmapFont);


switch (m_state)
{
case GameState::MENU:
DrawText(m_width * 0.5f, m_height * 0.5f, "Asteroid", m_bitmapFont);
break;
case GameState::RESPAWN:
// BLINK
if(m_playerRespawnWait % WORLD_BLINK_RATE == 0)
Expand Down Expand Up @@ -186,7 +185,10 @@ namespace asteroids

void World::OnMouseClick(int button, int state, int x, int y)
{

if(m_state == GameState::MENU)
{
m_state = GameState::PLAYING;
}
}

float World::GetWidth() const
Expand Down
1 change: 1 addition & 0 deletions src/World.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace asteroids {

enum GameState
{
MENU,
PLAYING,
RESPAWN
};
Expand Down

0 comments on commit e5fd060

Please sign in to comment.