Sunday, February 26, 2012

Audio Player Class

I am currently implementing the audio class i have created my own test project the i will add the necessary sound component to the mainline when i am done to avoid mainline chocking.


this is what i got so-far:

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using System.Text;

namespace Tetris
{
public enum Sound
{
SND_ROTATE,
SND_HARD_DROP,
SND_START_GAME,
SND_GAME_OVER,
}

public class AudioPlayer
{
//
// Other data structures needed to be decided by implementation team
//

static AudioPlayer instance;
public static AudioPlayer Instance
{
get
{
if (instance == null)
{
instance = new AudioPlayer();
}
return instance;
}
}

private AudioPlayer()
{
this.audioEngine = null;
this.soundBank = null;
this.waveBank = null;

//
this.hard_drop_sound = null;
this.rotate_sound = null;
this.start_game_sound = null;
this.game_over_sound = null;
}

~AudioPlayer()
{
}

public void Initialize()
{
audioEngine = new AudioEngine("Content\\TetrisSound.xgs");
soundBank = new SoundBank(audioEngine, "Content\\Tetris Sound Bank.xsb");
waveBank = new WaveBank(audioEngine, "Content\\Tetris Wave Bank.xwb");

hard_drop_sound = soundBank.GetCue("hard_drop");
rotate_sound = soundBank.GetCue("rotate");
start_game_sound = soundBank.GetCue("soundTrackMain");
game_over_sound = soundBank.GetCue("soundTrackMain");

}

public void playSound(Sound sound)
{
switch (sound)
{
case Sound.SND_START_GAME:
start_game_sound.Play();
break;
case Sound.SND_GAME_OVER:
game_over_sound.Play();
break;
case Sound.SND_HARD_DROP:
hard_drop_sound.Play();
break;
case Sound.SND_ROTATE:
rotate_sound.Play();
break;
}
}

public void startMusic() { }

public void stopMusic() { }

public Cue hard_drop_sound;
public Cue rotate_sound;
public Cue start_game_sound;
public Cue game_over_sound;

public AudioEngine audioEngine;
public SoundBank soundBank;
public WaveBank waveBank;
}
}

So long and stay thirst my friends.

Thursday, February 23, 2012

Bucket design

For this assignment we decided as a team that each one of us design our bucket data structure
then choose the one we thought was the most easy one to implement. Then after choosing the
design we all worked on improving it, once this was all finalized we devided the tasks
accordingly. I was assigned to do documentation requirements, for the implemetation team,
meaning how we wanted the implementation to be commented. Yet again we came through as a
team and completed the assignment on time.

So long and stay thirst my friends.

Project 2

For this project i was assigned to implement three methods for the Spin design. These methods
are: removeNode(), removeNodeAt(), and addToEnd(). Based on my previous experience with the doubbly linkedList this was not to difficult at all. The removeNode method take a Node parameter to be removed and the removeNodeAt takes an index of number for the node to be removed. For the addToEnd method just need to add the node at the end of the list, by getting the tail of the list then the added Node becomes the tail.. Working with the team was not a problem everyone did their fair share.


So long and stay thirst my friends.

Monday, January 23, 2012

Unit Testing

After doing homework 2, my team and i started working the next assignment for unit testing i know it it going to be interesting, believe it or not the idea of unity testing is new to me, but dont getting wrong i am willing to learn this stuff in and out. Hopefuly i will be able to use this skill from now untill i cant code anymore god knows when.

So long and stay thirst my friends..

Thursday, January 12, 2012

Fibonacci Homework

Ok, It is all again back to to basics, by that i mean going back to doing baby steps. I am new to C#
but i will try my best to learn it and understand it better, hoping by the end of this quarter i will have a better understanding it. I finished doing the fibonacci number sequence and the code below shows how i did it, it may not be the best way of doing it but it works:

//This function calculates the fibonacci numbers
//and prints them individually
static void FibanaciNumbers(int num)
{
int prevNumber = 0;
int result = 0;

int tempResult = 0;
for(int i=0; i<= num; i++)
{

if (i == 1 == 2)
{
//In the fibonacci sequence the fibonacci number 2 and 3
// will always be 1, so for not wasting time we just check
//if the numbers are 2 and 3 we just assign our result and
//previus number variables to our.
prevNumber = 1;
result = 1;
tempResult = 1;
}
else
{
//we take the current prevNumber and add it to the result
//then take the sum and store it in a temporary variable
//then assign the result value to the previous and take
//the temporary result and assign it as our result. The result is
//our fibonacci number and we prints it out.
tempResult = prevNumber + result;
prevNumber = result;
result = tempResult;
}
//prints the number to the console
Console.WriteLine(" Fibonacci Number: " + result);
}
}

So long and stay thirst my firends.