LAMPIRAN 1 FOTO-FOTO ANAK DALAM MEMPRAKTEKKAN SISTEM SEBAGAI BUKTI PENELITIAN
LAMPIRAN 1 FOTO-FOTO ANAK DALAM MEMPRAKTEKKAN SISTEM SEBAGAI BUKTI PENELITIAN
LAMPIRAN 2 ASESMEN ANAK BAHWASANNYA BENAR MENDERITA PENYAKIT DISLEKSIA
LAMPIRAN 3
SAMPLE SEBAGAI PEMBELAJARAN MENGENAL ANGKA, HURUF, DAN
Angka
Angka Dasar Value
1
“satu”
2
“dua”
3
“tiga”
4 “empat”
5
“lima”
6
“enam”
Text
“nol”
8 “delapan”
9 “sembilan”
Angka Serupa
38 “tiga puluh delapan”
83 “delapan puluh tiga”
69 “enam puluh sembilan”
96 “sembilan puluh enam”
52 “limah puluh dua”
7
“tujuh”
25 “dua puluh lima”
71 “tujuh puluh satu”
17 “tujuh belas”
Huruf Value
Text
Aa
“ a”
Bb
“ b”
Cc
“ c”
Dd
“ d”
Ee
Ff
Gg
Hh
Ii
Jj
“ j”
“ h”
“ g”
“ f”
“ e”
“ i”
Kk
Ll
Mm
“ m”
“ k”
“ l”
Nn
“ o”
“ n” Oo
Pp
“ p”
Rr
“ r”
Ss
“ s”
Tt
“ t”
Uu
“ u”
“ q”
Vv
Ww
“ x”
“ w”
“ v”
Xx
Yy
“ y” Zz
“ z”
Kata Value
Text bibi
“ bibi” didi
“ didi” rara
“ rara” nana
“ nana” mama
“ mama” wawa
“ wawa” dadu
“ dadu” babu
“ babu” buku
“ buku” duku
“ duku”
LAMPIRAN 4
LISTING PROGRAM
// Halaman Game1.cs
using System; using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.GamerServices; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Media; namespace AlGame
{
/// <summary> /// This is the main type for your game /// </summary> public class Game1 : Microsoft.Xna.Framework. Game
{
GraphicsDeviceManager graphics; SpriteBatch spriteBatch; public static SoundEffect MENU_SOUND;
public static SoundEffectInstance MENU_SOUND_INSTANCE; //The screen and the current screen Screen mCurrentScreen; HomeScreen mHomeScreen; LevelScreen mLevelScreen; AboutScreen mAboutScreen; PlayScreen mPlayScrren; SubLevelScreen mSubLevelScreen; HowToPlay mHowToPlayScreen; // cursor public static Texture2D CURSOR_CSTM; public static Vector2 CURSOR_POS; // static sound effect public static SoundEffect MOUSE_DOWN; //Static variabel for screen name public static double HOME = 1; public static double PLAY = 2; public static double HOW_TO_PLAY = 3; public static double ABOUT = 4; public static double LEVEL_SCREEN = 5; public static double LEVEL1 = 1.1; public static double LEVEL11 = 1.11; public static double LEVEL12 = 1.12; public static double LEVEL2 = 2.2; public static double LEVEL21 = 2.21; public static double LEVEL22 = 2.22; public static double LEVEL3 = 3.3; public Game1()
{ graphics = new GraphicsDeviceManager ( this ); Content.RootDirectory = "Content" ; graphics.PreferredBackBufferHeight = 600; graphics.PreferredBackBufferWidth = 800;
//this.IsMouseVisible = true;
}
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well.
/// </summary> protected override void Initialize()
{
// TODO: Add your initialization logic here base .Initialize();
}
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content.
/// </summary> protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch (GraphicsDevice); CURSOR_CSTM = Content.Load< Texture2D >( "image/cursor_action_t" );
// TODO: use this.Content to load your game content here //Initialize the various screens in the game
mHomeScreen = new HomeScreen ( this .Content,
this .GraphicsDevice, new EventHandler (HomeScreenEvent));
mLevelScreen = new LevelScreen ( this .Content,
this .GraphicsDevice, new EventHandler (LevelScreenEvent));
mAboutScreen = new AboutScreen ( this .Content,
this .GraphicsDevice, new EventHandler (AboutScreenEvent));
mHowToPlayScreen = new HowToPlay ( this .Content,
this .GraphicsDevice, new EventHandler (HowToPlayEvent)); //Set the current screen
mCurrentScreen = mHomeScreen;
// static sound effent
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime"> Provides a snapshot of timing values. </param> protected override void Update( GameTime gameTime)
}
base .Update(gameTime);
mCurrentScreen.Update(gameTime); CURSOR_POS = new Vector2 (mouse.X, mouse.Y);
MouseState mouse = Mouse .GetState(); // TODO: Add your update logic here
//KeyboardState keyboard = Keyboard.GetState();
//if (keyboard.IsKeyDown(Keys.W)) { MySpiretPosition.Y -= 5; } //if (keyboard.IsKeyDown(Keys.S)) { MySpiretPosition.Y += 5; } //if (keyboard.IsKeyDown(Keys.D)) { MySpiretPosition.X += 5; } //if (keyboard.IsKeyDown(Keys.A)) { MySpiretPosition.X -= 5; }ButtonState .Pressed) this .Exit();
// Allows the game to exit if ( GamePad .GetState( PlayerIndex .One).Buttons.Back ==
{
}
MOUSE_DOWN =
// TODO: Unload any non ContentManager content here
{
/// </summary> protected override void UnloadContent()
/// <summary> /// UnloadContent will be called once per game and is the place to unload /// all content.
MENU_SOUND_INSTANCE = MENU_SOUND.CreateInstance(); MENU_SOUND_INSTANCE.IsLooped = true ; MENU_SOUND_INSTANCE.Play(); }
this .Content.Load< SoundEffect >( "sound/menu" );
MENU_SOUND =
this .Content.Load< SoundEffect >( "sound/mousedown" );
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime"> Provides a snapshot of timing values. </param> protected override void Draw( GameTime gameTime)
{ GraphicsDevice.Clear( Color .CornflowerBlue);
// TODO: Add your drawing code here
spriteBatch.Begin(); mCurrentScreen.Draw(spriteBatch); spriteBatch.Draw( Game1 .CURSOR_CSTM, Game1 .CURSOR_POS,
Color .White);
spriteBatch.End();
base .Draw(gameTime);
}
//This event fires when the Controller detect screen is returning control back to the main game class public void HomeScreenEvent( object obj, EventArgs
e) {
//Switch to the title screen, the Controller detect screen is finished being displayed if (( double )obj == Game1 .ABOUT)
{ mCurrentScreen = mAboutScreen; }
else if (( double )obj == Game1 .LEVEL_SCREEN)
{ mCurrentScreen = mLevelScreen; }
else if (( double )obj == Game1 .HOW_TO_PLAY)
{ mCurrentScreen = mHowToPlayScreen; } }
public void AboutScreenEvent( object obj, EventArgs
e) { mCurrentScreen = mHomeScreen; }
public void HowToPlayEvent( object obj, EventArgs
e) { mCurrentScreen = mHomeScreen; }
public void LevelScreenEvent( object obj, EventArgs
e) {
if (( double )obj == Game1 .HOME)
{ mCurrentScreen = mHomeScreen; }
else if (( double )obj == Game1 .LEVEL1)
{
SubLevelScreen .LEVEL = Game1 .LEVEL1;
mSubLevelScreen = new SubLevelScreen ( this .Content,
this .GraphicsDevice, new EventHandler (SubLevelEvent)); mCurrentScreen = mSubLevelScreen; }
else if (( double )obj == Game1 .LEVEL2)
{
SubLevelScreen .LEVEL = Game1 .LEVEL2;
mSubLevelScreen = new SubLevelScreen ( this .Content,
this .GraphicsDevice, new EventHandler (SubLevelEvent));
mCurrentScreen = mSubLevelScreen; }
else if (( double )obj == Game1 .LEVEL3)
{
PlayScreen .SUB_LEVEL = Game1 .LEVEL3;
mPlayScrren = new PlayScreen ( this .Content,
this .GraphicsDevice, new EventHandler (PlayScreenEvent));
mCurrentScreen = mPlayScrren; } }
public void SubLevelEvent( object obj, EventArgs
e) {
if (( double )obj == Game1 .LEVEL_SCREEN)
{ mCurrentScreen = mLevelScreen; }
else if (( double )obj == Game1 .LEVEL11)
{
PlayScreen .SUB_LEVEL = Game1 .LEVEL11;
mPlayScrren = new PlayScreen ( this .Content,
this .GraphicsDevice, new EventHandler (PlayScreenEvent));
mCurrentScreen = mPlayScrren; }
else if (( double )obj == Game1 .LEVEL12)
{
PlayScreen .SUB_LEVEL = Game1 .LEVEL12;
mPlayScrren = new PlayScreen ( this .Content,
this .GraphicsDevice, new EventHandler (PlayScreenEvent));
mCurrentScreen = mPlayScrren; }
else if (( double )obj == Game1 .LEVEL21)
{
PlayScreen .SUB_LEVEL = Game1 .LEVEL21;
mPlayScrren = new PlayScreen ( this .Content,
this .GraphicsDevice, new EventHandler (PlayScreenEvent));
mCurrentScreen = mPlayScrren; }
else if (( double )obj == Game1 .LEVEL22)
{
PlayScreen .SUB_LEVEL = Game1 .LEVEL22;
mPlayScrren = new PlayScreen ( this .Content,
this .GraphicsDevice, new EventHandler (PlayScreenEvent));
mCurrentScreen = mPlayScrren; }
else
{ mCurrentScreen = mSubLevelScreen;
} }
public void PlayScreenEvent( object obj, EventArgs
e) {
if (( double )obj == Game1 .LEVEL1)
{
SubLevelScreen .LEVEL = Game1 .LEVEL1;
mSubLevelScreen = new SubLevelScreen ( this .Content,
this .GraphicsDevice, new EventHandler (SubLevelEvent));
mCurrentScreen = mSubLevelScreen; }
else if (( double )obj == Game1 .LEVEL2)
{
SubLevelScreen .LEVEL = Game1 .LEVEL2;
mSubLevelScreen = new SubLevelScreen ( this .Content,
this .GraphicsDevice, new EventHandler (SubLevelEvent));
mCurrentScreen = mSubLevelScreen; }
else
{ mCurrentScreen = mLevelScreen; } MENU_SOUND_INSTANCE.Play(); } } } // LevelScreen.cs
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml.Linq; using System.Threading; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Input; using System.IO; namespace AlGame
{
class LevelScreen : Screen
{
Texture2D bgTexture; Rectangle bgPosition; Rectangle level1Position; Texture2D btnLevel1; Rectangle level2Position; Texture2D btnLevel2;
Rectangle level3Position; Texture2D btnLevel3; Texture2D btnKembali; Texture2D btnKembaliActive; Texture2D btnKembaliHover; Rectangle btnKembaliPosition; Texture2D lockImg; public LevelScreen( ContentManager theContent, GraphicsDevice
graphicDevice, EventHandler theScreenEvent) : base (theScreenEvent) { bgPosition = new Rectangle (0, 0, graphicDevice.Viewport.Width, graphicDevice.Viewport.Height); bgTexture = theContent.Load< Texture2D >( "image/bg" ); level1Position = new Rectangle (90, 64, 150, 233); btnLevel1 = theContent.Load< Texture2D >( "image/number_animals_1" ); level2Position = new Rectangle (307, 255, 180, 216); btnLevel2 = theContent.Load< Texture2D >( "image/number_animals_2" ); level3Position = new Rectangle (560, 118, 180, 235); btnLevel3 = theContent.Load< Texture2D >( "image/number_animals_3" ); btnKembaliActive = theContent.Load< Texture2D >( "image/kembali-active" ); btnKembaliHover = theContent.Load< Texture2D >( "image/kembali-hover" ); btnKembali = btnKembaliActive; btnKembaliPosition = new Rectangle (100, 521, 150, 35); lockImg = theContent.Load< Texture2D >( "image/lock" ); }
//Update all of the elements that need updating in the
Controller Detect Screen public override void Update( GameTime theTime){
MouseState mouse = Mouse .GetState();
if (mouse.LeftButton == ButtonState .Pressed)
{
Point pointer = new Point (mouse.X, mouse.Y); if (btnKembaliPosition.Contains(pointer))
{
Game1 .MOUSE_DOWN.Play();
ScreenEvent.Invoke( Game1 .HOME, new EventArgs ());
return ;
}
else if (level1Position.Contains(pointer))
{
Thread .Sleep(200); Game1 .MOUSE_DOWN.Play();
ScreenEvent.Invoke( Game1 .LEVEL1, new
EventArgs ()); return ;
}
else if (level2Position.Contains(pointer))
{
Thread .Sleep(200); Game1 .MOUSE_DOWN.Play();
ScreenEvent.Invoke( Game1 .LEVEL2, new
EventArgs ()); return ;
}
else if (level3Position.Contains(pointer))
{
Thread .Sleep(200); Game1 .MOUSE_DOWN.Play();
ScreenEvent.Invoke( Game1 .LEVEL3, new
EventArgs ()); return ;
} }
Rectangle hoverPosition = new Rectangle (mouse.X, mouse.Y,
1, 1);
if (hoverPosition.Intersects(btnKembaliPosition))
{ btnKembali = btnKembaliHover; }
else
{ btnKembali = btnKembaliActive; }
base .Update(theTime);
}
//Draw all of the elements that make up the Controller Detect Screen public override void Draw( SpriteBatch spriteBatch)
{ spriteBatch.Draw(bgTexture, bgPosition, Color .White); spriteBatch.Draw(btnKembali, btnKembaliPosition,
Color .White);
spriteBatch.Draw(btnLevel1, level1Position, Color .White); spriteBatch.Draw(btnLevel2, level2Position, Color .White); spriteBatch.Draw(btnLevel3, level3Position, Color .White);
//for lock level 2 //spriteBatch.Draw(lockImg, new Rectangle(390, 320, 140, 130), Color.White); //for lock level 3
//spriteBatch.Draw(lockImg, new Rectangle(631, 228, 140, 130), Color.White); base .Draw(spriteBatch);
} } } // HowToPlay.cs
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Input; namespace AlGame
{
class HowToPlay : Screen
{
/* Background */ Texture2D bgTexture; Rectangle bgPossition; Texture2D btnKembali; Texture2D btnKembaliActive; Texture2D btnKembaliHover; Rectangle btnKembaliPosition; SpriteFont normalFont; public HowToPlay( ContentManager theContent, GraphicsDevice
graphicDevice, EventHandler theScreenEvent) : base (theScreenEvent) { bgPossition = new Rectangle (0, 0, graphicDevice.Viewport.Width, graphicDevice.Viewport.Height); bgTexture = theContent.Load< Texture2D >( "image/home" ); btnKembaliActive = theContent.Load< Texture2D >( "image/kembali-active" ); btnKembaliHover = theContent.Load< Texture2D >( "image/kembali-hover" ); btnKembali = btnKembaliActive; btnKembaliPosition = new Rectangle (100, 521, 150, 35); normalFont = theContent.Load< SpriteFont >( "normalFont" ); }
//Update all of the elements that need updating in the
Controller Detect Screen public override void Update( GameTime theTime){
KeyboardState keyboard = Keyboard .GetState(); if (keyboard.IsKeyDown( Keys .Back)) {
ScreenEvent.Invoke( this , new EventArgs ());
return ;
}
MouseState mouse = Mouse .GetState();
if (mouse.LeftButton == ButtonState .Pressed)
{
Point pointer = new Point (mouse.X, mouse.Y); if (btnKembaliPosition.Contains(pointer))
{
Game1 .MOUSE_DOWN.Play();
ScreenEvent.Invoke( this , new EventArgs ());
return ;
} }
Rectangle hoverPosition = new Rectangle (mouse.X, mouse.Y,
1, 1);
if (hoverPosition.Intersects(btnKembaliPosition))
{ btnKembali = btnKembaliHover; }
else
{ btnKembali = btnKembaliActive; } }
//Draw all of the elements that make up the Controller Detect Screen public override void Draw( SpriteBatch spriteBatch)
{ spriteBatch.Draw(bgTexture, bgPossition, Color .White); spriteBatch.Draw(btnKembali, btnKembaliPosition,
Color .White);
spriteBatch.DrawString(normalFont, "Aplikasi ini
- merupakan jenis game puzle dimana \n"
"bertujuan sebagai sarana pelatihan dan pembelajaran \n"
- "anak-anak yang mengalamai kondisi ketidakmampuan bel
- \n"
"yang disebabkan oleh kesulitan dalam melakukan
- aktiviatas\n"
"membaca dan menulis (dyslexia). Game ini terbagi dalam 3
- level. \n"
"Untuk memulai, silahkan klik tombol mulai dan level yang
- \n"
"ingin dimainkan. Kemudian akan muncul soal yang
- sesuai\n"
"dengan level yang Anda pilih. Anda sebutkan angka\\ \n"
- "huruf\\kata yang mucul. Jika Anda benar, skor akan \n"
- "ditambahkan 1. Pemainan akan berhenti setelah \n&q
- "aplikasi memunculkan 5 soal yang berbeda di \n"
"setiap level." , new Vector2 (100, 250), Color .White); base .Draw(spriteBatch);
} } } // AboutScreen.cs
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Input; namespace AlGame
{
class AboutScreen : Screen
{
/* Background */ Texture2D bgTexture; Rectangle bgPossition; Texture2D btnKembali; Texture2D btnKembaliActive; Texture2D btnKembaliHover; Rectangle btnKembaliPosition; Texture2D logoUSU; Rectangle logoUSUPosition; SpriteFont normalFont; public AboutScreen( ContentManager theContent, GraphicsDevice
graphicDevice, EventHandler theScreenEvent) : base (theScreenEvent) { bgPossition = new Rectangle (0, 0, graphicDevice.Viewport.Width, graphicDevice.Viewport.Height); bgTexture = theContent.Load< Texture2D >( "image/home" ); btnKembaliActive = theContent.Load< Texture2D >( "image/kembali-active" ); btnKembaliHover = theContent.Load< Texture2D >( "image/kembali-hover" ); btnKembali = btnKembaliActive; btnKembaliPosition = new Rectangle (100, 521, 150, 35); logoUSU = theContent.Load< Texture2D >( "image/logo usu" ); logoUSUPosition = new Rectangle (350, 450, 100, 100); normalFont = theContent.Load< SpriteFont >( "normalFont" ); }
//Update all of the elements that need updating in the
Controller Detect Screen public override void Update( GameTime theTime){
KeyboardState keyboard = Keyboard .GetState();
if (keyboard.IsKeyDown( Keys .Back)) {ScreenEvent.Invoke( this , new EventArgs ());
return ;
}
MouseState mouse = Mouse .GetState();
if (mouse.LeftButton == ButtonState .Pressed)
{
Point pointer = new Point (mouse.X, mouse.Y); if (btnKembaliPosition.Contains(pointer))
{
Game1 .MOUSE_DOWN.Play();
ScreenEvent.Invoke( this , new EventArgs ());
return ;
} }
Rectangle hoverPosition = new Rectangle (mouse.X, mouse.Y,
1, 1);
if (hoverPosition.Intersects(btnKembaliPosition))
{ btnKembali = btnKembaliHover; }
else
{ btnKembali = btnKembaliActive; } }
//Draw all of the elements that make up the Controller Detect Screen public override void Draw( SpriteBatch spriteBatch)
{ spriteBatch.Draw(bgTexture, bgPossition, Color .White); spriteBatch.Draw(btnKembali, btnKembaliPosition,
Color .White);
spriteBatch.DrawString(normalFont, "Aplikasi ini
- dikembangkan oleh \"Alman Julinius Tarigan\". \n"
"Aplikasi ini dikembangkan dalam rangka penelitian
- skripsi \n"
"yang merupakan salah satu syarat kelulusan mahasiswa \n"
- "Teknik Informasi, Universitas Sumatera Utara. \n \n"
- "Aplikasi ini dibangun dengan menggunakan Microsoft \n&q
- "Speech Recognizer (Microsoft SAPI) sebagai engine \n"
- "untuk pengenalan suara dan Microsoft XNA Framework \n"
"sebagai game platform. \n \n" +
"Copyright 2014 - Alman Julinius Tarigan" , new
Vector2 (100, 250), Color .White);spriteBatch.Draw(logoUSU, logoUSUPosition, Color .White);
base .Draw(spriteBatch);
} } } // PlayScreen.cs
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using AlGameObject; using Microsoft.Xna.Framework.Input; using System.Threading; using System.Windows.Forms; namespace AlGame
{
class PlayScreen : Screen
{
Texture2D bgTexture; Rectangle bgPosition; Texture2D textInfo; Rectangle textInfoPosition; Texture2D btnKembali; Rectangle btnKembaliPosition; SAPIEngine sapi; SpriteFont font; SpriteFont gameFont; SpriteFont finishFont; SoundEffect levelStartSound; SoundEffectInstance levelStartInstance; SoundEffect levelSound; SoundEffectInstance levelSoundInstance; SoundEffect trueSound; SoundEffect falseSound; SoundEffect winSound; SoundEffect loseSound; int jumlahSoal = 5; int benar = 0; List < string > listSoal; String soal; bool newSoal = true ; bool selesai = false ; bool selesaiSound = true ; int viewPortWidth; bool next = false ; List < Soal > listSoalHurufKata; Soal currentSoal; public static double SUB_LEVEL = 1.11; public PlayScreen( ContentManager theContent, GraphicsDevice
graphicDevice, EventHandler theScreenEvent) : base (theScreenEvent) { bgPosition = new Rectangle (0, 0, graphicDevice.Viewport.Width, graphicDevice.Viewport.Height); viewPortWidth = graphicDevice.Viewport.Width; bgTexture = theContent.Load< Texture2D >( "image/bg" ); btnKembali = theContent.Load< Texture2D >( "image/kembali-
active" );
btnKembaliPosition = new Rectangle (100, 521, 150, 35); font = theContent.Load< SpriteFont >( "MenuFont" ); gameFont = theContent.Load< SpriteFont >( "gameFont" ); finishFont = theContent.Load< SpriteFont >( "finishedText" );
if (SUB_LEVEL == Game1 .LEVEL11)
{
var xml = theContent.Load< List < Kata >>( "data/level1" );
sapi = new SAPIEngine (xml); textInfo = theContent.Load< Texture2D >( "image/level1msg" ); textInfoPosition = new Rectangle (107, 80, 600, 60); levelSound = theContent.Load< SoundEffect >( "sound/angka_apa_ini" ); } else if (SUB_LEVEL == Game1 .LEVEL12) {
var xml =
theContent.Load< List < Kata >>( "data/level12" ); sapi = new SAPIEngine (xml); textInfo = theContent.Load< Texture2D >( "image/level1msg" ); textInfoPosition = new Rectangle (107, 80, 600, 60); levelSound = theContent.Load< SoundEffect >( "sound/angka_apa_ini" ); } else if (SUB_LEVEL == Game1 .LEVEL21) {
var xml =
theContent.Load< List < Kata >>( "data/level21" ); sapi = new SAPIEngine (xml); textInfo = theContent.Load< Texture2D >( "image/level2msg" ); textInfoPosition = new Rectangle (107, 80, 600, 60); levelSound = theContent.Load< SoundEffect >( "sound/huruf_apa_ini" ); }
else if (SUB_LEVEL == Game1 .LEVEL22)
{
var xml =
theContent.Load< List < Kata >>( "data/level21" ); sapi = new SAPIEngine (xml); textInfo = theContent.Load< Texture2D >( "image/level2msg" ); textInfoPosition = new Rectangle (107, 80, 600, 60); listSoalHurufKata = theContent.Load< List < Soal >>( "data/level22" ); levelSound = theContent.Load< SoundEffect >( "sound/huruf_apa_ini" ); }
else if (SUB_LEVEL == Game1 .LEVEL3)
{
var xml =
theContent.Load< List < Kata >>( "data/level3data" ); sapi = new SAPIEngine (xml); textInfo = theContent.Load< Texture2D >( "image/level3msg" ); textInfoPosition = new Rectangle (107, 80, 600, 60); listSoalHurufKata = theContent.Load< List < Soal >>( "data/level3soal" ); levelSound = theContent.Load< SoundEffect >( "sound/kata_apa_ini" ); } trueSound = theContent.Load< SoundEffect >( "sound/true_sound" ); falseSound = theContent.Load< SoundEffect >( "sound/false_sound" ); winSound = theContent.Load< SoundEffect >( "sound/minigame_win" ); loseSound = theContent.Load< SoundEffect >( "sound/minigame_lose" ); levelStartSound = theContent.Load< SoundEffect >( "sound/level_start" ); levelStartInstance = levelStartSound.CreateInstance(); levelStartInstance.Volume = 0.2f; levelStartInstance.Play(); levelSoundInstance = levelSound.CreateInstance(); levelSoundInstance.Play(); listSoal = new List < string >(); soal = "" ;
Game1 .MENU_SOUND_INSTANCE.Stop();
}
//Update all of the elements that need updating in the
Controller Detect Screen public override void Update( GameTime theTime){
MouseState mouse = Mouse .GetState(); if (mouse.LeftButton ==
Microsoft.Xna.Framework.Input. ButtonState .Pressed) {
Point pointer = new Point (mouse.X, mouse.Y); if (btnKembaliPosition.Contains(pointer))
{
Game1 .MOUSE_DOWN.Play(); Thread .Sleep(200);
sapi.stopListening(); sapi.unload();
if (SUB_LEVEL == Game1 .LEVEL11 || SUB_LEVEL == Game1 .LEVEL12)
{ ScreenEvent.Invoke( Game1 .LEVEL1, new
EventArgs ()); return ;
}
else if (SUB_LEVEL == Game1 .LEVEL21 || SUB_LEVEL
== Game1 .LEVEL22) { ScreenEvent.Invoke( Game1 .LEVEL2, new
EventArgs ()); return ;
}
else
{ ScreenEvent.Invoke( Game1 .LEVEL_SCREEN, new
EventArgs ()); return ;
} } }
if (levelStartInstance.State == SoundState .Stopped &&
levelSoundInstance.State == SoundState .Stopped) {
if (!selesai)
{
if (newSoal)
{
if (listSoal.Count < jumlahSoal)
{ drawSoal(); newSoal = false ; sapi.prepareNewListening(); sapi.startListening();
Thread .Sleep(200);
}
else
{ newSoal = false ; } }
if (sapi.getResult)
{
//MessageBox.Show(sapi.soal + " " + sapi.isTrue); if (sapi.isTrue)
{ benar += 1; trueSound.Play(); }
else
{ falseSound.Play(); } sapi.stopListening();
Thread .Sleep(200);
newSoal = true ;
/* check selesai atau tidak */ if (listSoal.Count >= jumlahSoal)
{ selesai = true ; } } }
else
{
//MessageBox.Show("Selesai");
} }
base .Update(theTime);
}
//Draw all of the elements that make up the Controller Detect Screen public override void Draw( SpriteBatch spriteBatch)
{ spriteBatch.Draw(bgTexture, bgPosition, Color .White); spriteBatch.Draw(textInfo, textInfoPosition,
Color .White);
spriteBatch.Draw(btnKembali, btnKembaliPosition,
Color .White);
spriteBatch.DrawString(font, "Jumlah soal : " + jumlahSoal, new Vector2 (20, 10), Color .White); spriteBatch.DrawString(font, "Score : " + benar, new
Vector2 (20,40), Color .White); if (selesai) {
if (( double )benar / jumlahSoal > 0.5)
{
string msg = "Selamat!! Anda berhasil" ;
spriteBatch.DrawString(finishFont, msg, new
Vector2 ((viewPortWidth / 2) - (finishFont.MeasureString(msg).X / 2),
260), Color .White);
if (selesaiSound) { winSound.Play(); }
} else {
string msg = "Maaf, Silahkan coba sekali lagi!" ;
spriteBatch.DrawString(finishFont, msg, new
Vector2 ((viewPortWidth / 2) - (finishFont.MeasureString(msg).X / 2),
260), Color .White);
if (selesaiSound) { loseSound.Play(); }
} selesaiSound = false ; }
else
{ spriteBatch.DrawString(gameFont, soal, new
Vector2 ((viewPortWidth /2) - (gameFont.MeasureString(soal).X / 2),
260), Color .White); }
base .Draw(spriteBatch);
}
public void drawSoal()
{
Random rnd = new Random (); int i = 0;
if (SUB_LEVEL == Game1 .LEVEL22 || SUB_LEVEL ==
Game1 .LEVEL3)
{
if (next)
{
var data = ( from s in sapi.words where s.Text == currentSoal.Pasangan select s).FirstOrDefault();
soal = data.Value; sapi.soal = data.Text; listSoal.Add(currentSoal.Pasangan); next = false ; }
else
{ i = rnd.Next(0, listSoalHurufKata.Count - 1);
while
(listSoal.Contains(listSoalHurufKata[i].Data)) { i = rnd.Next(0, listSoalHurufKata.Count - 1); } currentSoal = listSoalHurufKata[i];
var data = ( from s in sapi.words where s.Text == currentSoal.Data select s).FirstOrDefault(); soal = data.Value; sapi.soal = data.Text; listSoal.Add(currentSoal.Data); next = true ; } }
else
{ i = rnd.Next(0, sapi.words.Count - 1);
while (listSoal.Contains(sapi.words[i].Value))
{ i = rnd.Next(0, sapi.words.Count - 1); } soal = sapi.words[i].Value; sapi.soal = sapi.words[i].Text; listSoal.Add(soal); } } } } Program.cs
using System; namespace AlGame
{
#if WINDOWS || XBOX static class Program
{
/// <summary> /// The main entry point for the application. /// </summary> static void Main( string [] args)
{
using ( Game1 game = new Game1 ())
{ game.Run(); } } }
#endif
} // SAPIEngines.cs
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Speech.Recognition; using System.Windows.Forms; using System.IO; using System.Diagnostics; using AlGameObject; namespace AlGame
{
class SAPIEngine
{
//Speech Recognition Engine public SpeechRecognitionEngine speechRecognitionEngine = null ; // List of text to recognizing public List < Kata > words = new List < Kata >(); public String soal; public bool isTrue; public bool getResult; public SAPIEngine( List < Kata > kata)
{
try
{ words = kata;
// create the engine
speechRecognitionEngine = createSpeechEngine( "en-
US" ); // hook to events //speechRecognitionEngine.AudioLevelUpdated += new
EventHandler<AudioLevelUpdatedEventArgs>(engine_AudioLevelUpdated);
speechRecognitionEngine.SpeechRecognized += new
EventHandler < SpeechRecognizedEventArgs >(speechRecognitionEngine_Speec
hRecognized);
//speechRecognitionEngine.SpeechDetected += new
EventHandler<SpeechDetectedEventArgs>(speechRecognitionEngine_SpeechD
etected); //speechRecognitionEngine.SpeechHypothesized += newEventHandler<SpeechHypothesizedEventArgs>(speechRecognitionEngine_Spe
echHypothesized);// load dictionary
loadGrammarAndCommands();
// use the system's default microphone
speechRecognitionEngine.SetInputToDefaultAudioDevice(); }
catch ( Exception
e) {
MessageBox .Show(e.Message, "Voice recognition failed" );
} }
/// <summary>
/// Creates the speech engine. /// </summary> /// <param name="preferredCulture"> The preferred culture. </param>
/// <returns></returns> private SpeechRecognitionEngine createSpeechEngine( string
preferredCulture) {
foreach ( RecognizerInfo config in SpeechRecognitionEngine .InstalledRecognizers())
{
if (config.Culture.ToString() == preferredCulture)
{ speechRecognitionEngine = new
SpeechRecognitionEngine (config); break ;
} }
// if the desired culture is not found, then load default if (speechRecognitionEngine == null )
{
MessageBox .Show( "The desired culture is not installed on this machine, the speech-engine will continue using "
SpeechRecognitionEngine .InstalledRecognizers()[0].Culture.ToString()
" as the default culture." , + "Culture " + preferredCulture + " not found!" );
speechRecognitionEngine = new
SpeechRecognitionEngine ( SpeechRecognitionEngine .InstalledRecognizers(
)[0]); }
return speechRecognitionEngine;
}
/// <summary> /// Loads the grammar and commands. /// </summary> private void loadGrammarAndCommands()
{
try
{
Choices texts = new Choices (); foreach ( Kata item in words)
{
// add the text to the known choices of speechengine
texts.Add(item.Text); }
Grammar wordsList = new Grammar ( new GrammarBuilder (texts));
speechRecognitionEngine.LoadGrammar(wordsList); stopListening(); }
catch ( Exception ex)
{
throw ex;
} }
/// <summary> /// Handles the SpeechRecognized event of the engine control. /// </summary> /// <param name="sender"> The source of the event. </param> /// <param name="e"> The <see
cref="System.Speech.Recognition.SpeechRecognizedEventArgs"/> instance
containing the event data. </param> void speechRecognitionEngine_SpeechRecognized( object sender,SpeechRecognizedEventArgs
e) {
String msg = "" ;
msg += "\r " + e.Result.Text;
//MessageBox.Show(msg); if (e.Result.Text.Equals(soal))
{ isTrue = true ; }
else {
isTrue = false ; } getResult = true ; }
void speechRecognitionEngine_SpeechDetected( object sender, SpeechDetectedEventArgs
e) {
MessageBox .Show(e.AudioPosition.ToString());
}
void speechRecognitionEngine_SpeechHypothesized( object
sender, SpeechHypothesizedEventArgs
e) {
MessageBox .Show(e.Result.Text);
}
public void startListening()
{
// start listening
speechRecognitionEngine.RecognizeAsync( RecognizeMode .Multiple); }
public void stopListening()
{ speechRecognitionEngine.RecognizeAsyncStop(); }
public void unload()
{
// unhook events speechRecognitionEngine.RecognizeAsyncStop();
// clean references
speechRecognitionEngine.Dispose(); }
public void prepareNewListening()
{ getResult = false ; } } } // Screen.cs
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; namespace AlGame
{
class Screen
{
//The event associated with the Screen. This event is used to raise events
//back in the main game class to notify the game that
something has changed //or needs to be changed protected EventHandler ScreenEvent; public Screen( EventHandler theScreenEvent){ ScreenEvent = theScreenEvent; }
//Update any information specific to the screen public virtual void Update( GameTime theTime)
{ }
//Draw any objects specific to the screen public virtual void Draw( SpriteBatch theBatch)
{ } } } // SubLevelScreen.cs
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Input; namespace AlGame
{
class SubLevelScreen : Screen
{
Texture2D bgTexture; Rectangle bgPosition; Texture2D btnSubLevel1; Texture2D SubLevel1Active; Texture2D SubLevel1Hover; Rectangle btnSubLevel1Position; Texture2D btnSubLevel2; Texture2D SubLevel2Active; Texture2D SubLevel2Hover; Rectangle btnSubLevel2Position; Texture2D btnKembali; Texture2D btnKembaliActive; Texture2D btnKembaliHover; Rectangle btnKembaliPosition; public static double LEVEL; public SubLevelScreen( ContentManager theContent,
GraphicsDevice graphicDevice, EventHandler theScreenEvent)
: base (theScreenEvent) { bgPosition = new Rectangle (0, 0, graphicDevice.Viewport.Width, graphicDevice.Viewport.Height);
if (LEVEL == Game1 .LEVEL1)
{ SubLevel1Active = theContent.Load< Texture2D >( "image/btn-mengenal-angka-active" ); SubLevel1Hover = theContent.Load< Texture2D >( "image/btn-mengenal-angka-hover" ); SubLevel2Active = theContent.Load< Texture2D >( "image/btn-mengenal-angka-serupa-active" ); SubLevel2Hover = theContent.Load< Texture2D >( "image/btn-mengenal-angka-serupa-hover" ); }
else if (LEVEL == Game1 .LEVEL2)
{ SubLevel1Active = theContent.Load< Texture2D >( "image/btn-mengenal-huruf-active" ); SubLevel1Hover = theContent.Load< Texture2D >( "image/btn-mengenal-huruf-hover" ); SubLevel2Active = theContent.Load< Texture2D >( "image/btn-mengenal-huruf-serupa-active" );
SubLevel2Hover = theContent.Load< Texture2D >( "image/btn-mengenal-huruf-serupa-hover" ); } btnSubLevel1 = SubLevel1Active; btnSubLevel1Position = new Rectangle (152, 144, 225, 104); btnSubLevel2 = SubLevel2Active; btnSubLevel2Position = new Rectangle (152, 284, 225, 104); btnKembaliActive = theContent.Load< Texture2D >( "image/kembali-active" ); btnKembaliHover = theContent.Load< Texture2D >( "image/kembali-hover" ); btnKembali = btnKembaliActive; btnKembaliPosition = new Rectangle (100, 521, 150, 35); bgTexture = theContent.Load< Texture2D >( "image/bg-
sublevel" );
}
//Update all of the elements that need updating in the
Controller Detect Screen public override void Update( GameTime theTime){
MouseState mouse = Mouse .GetState();
if (mouse.LeftButton == ButtonState .Pressed)
{
Point pointer = new Point (mouse.X, mouse.Y); if (btnKembaliPosition.Contains(pointer))
{
Thread .Sleep(200); Game1 .MOUSE_DOWN.Play();
ScreenEvent.Invoke( Game1 .LEVEL_SCREEN, new
EventArgs ()); return ;
}
else if (btnSubLevel1Position.Contains(pointer))
{
Thread .Sleep(200); Game1 .MOUSE_DOWN.Play(); if (LEVEL == Game1 .LEVEL1)
{ ScreenEvent.Invoke( Game1 .LEVEL11, new
EventArgs ());
}
else if (LEVEL == Game1 .LEVEL2)
{ ScreenEvent.Invoke( Game1 .LEVEL21, new
EventArgs ());
}
return ;
}
else if (btnSubLevel2Position.Contains(pointer))
{
Thread .Sleep(200); Game1 .MOUSE_DOWN.Play(); if (LEVEL == Game1 .LEVEL1)