Created
April 3, 2011 13:06
-
-
Save OrigamiTech/900413 to your computer and use it in GitHub Desktop.
ported from a friend's friend's pascal source.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace guitar_hero | |
{ | |
class Program | |
{ | |
/*green,red,yellow,blue,cyan: left to right*/ | |
struct Tnote | |
{ | |
public short lane; | |
public short x_coord; | |
public short y_coord; | |
public bool exists; | |
} | |
static Tnote[] note = new Tnote[20]; | |
static char[] control = new char[5];/*user entered controls*/ | |
static char input; | |
static short delay_time; | |
static short i, number, count; | |
static char note_char; | |
static short note_gap; /*y axis distance between each note, used for spawning*/ | |
static short max_notes; /*maximum number of notes than can exist at one time*/ | |
static bool note_hit; | |
static short miss, ok, good; | |
static int score; | |
static short score_multiplier, multiplier_count; | |
static short score_gain_good, score_gain_ok; /*amount of score you gain for good/ok*/ | |
static void hit_check(short a) /*checks to see if you hit the note in the lane specified by the parameter*/ | |
{ | |
for(i = 0; i < max_notes; i++) | |
{ | |
/*it appears that input for ok/good/ok should be one higher on screen - maybe change the values y_coord by -1?*/ | |
if((note[i].lane == a) && ((note[i].y_coord == 21) || (note[i].y_coord == 23))) | |
{ | |
ok++; | |
note_hit = true; | |
note[i].exists = false; | |
score = score + (score_gain_ok * score_multiplier); | |
multiplier_count++; | |
if((multiplier_count == 6) && (score_multiplier < 5)) | |
{ | |
multiplier_count = 0; | |
score_multiplier++; | |
} | |
else if((score_multiplier == 5) && (multiplier_count > 5)) | |
multiplier_count = 5; | |
} | |
if((note[i].lane == a) && (note[i].y_coord == 22)) | |
{ | |
good++; | |
note_hit = true; | |
note[i].exists = false; | |
score = score + (score_gain_good * score_multiplier); | |
multiplier_count++; | |
if((multiplier_count == 6) && (score_multiplier < 5)) | |
{ | |
multiplier_count = 0; | |
score_multiplier++; | |
} | |
else if((score_multiplier == 5) && (multiplier_count > 5)) | |
multiplier_count = 5; | |
} | |
} | |
if(note_hit == false) | |
{ | |
miss++; | |
score_multiplier = 1; | |
multiplier_count = 0; | |
} | |
note_hit = false; | |
} /*procedure hit_check*/ | |
static void draw_ring(short a, short b, string colour) | |
{ | |
if(colour == "green") | |
Console.ForegroundColor = ConsoleColor.Green; | |
if(colour == "red") | |
Console.ForegroundColor = ConsoleColor.Red; | |
if(colour == "yellow") | |
Console.ForegroundColor = ConsoleColor.Yellow; | |
if(colour == "blue") | |
Console.ForegroundColor = ConsoleColor.Blue; | |
if(colour == "cyan") | |
Console.ForegroundColor = ConsoleColor.Cyan; | |
Console.SetCursorPosition(a - 2, b - 2); | |
Console.WriteLine('╔'); | |
Console.SetCursorPosition(a - 2, b - 1); | |
Console.WriteLine('║'); | |
Console.SetCursorPosition(a - 2, b); | |
Console.WriteLine('╚'); | |
Console.SetCursorPosition(a - 1, b - 2); | |
Console.WriteLine('═'); | |
Console.SetCursorPosition(a - 1, b); | |
Console.WriteLine('═'); | |
Console.SetCursorPosition(a, b - 2); | |
Console.WriteLine('╗'); | |
Console.SetCursorPosition(a, b - 1); | |
Console.WriteLine('║'); | |
Console.SetCursorPosition(a, b); | |
Console.WriteLine('╝'); | |
} /*procedure draw_ring*/ | |
static void drawgame() | |
{ | |
Console.Clear(); | |
Console.ForegroundColor = ConsoleColor.Black; | |
for(i = 0; i < 24; i++) | |
{ | |
Console.SetCursorPosition(29 - 1, i); | |
Console.Write('║'); | |
Console.SetCursorPosition(51 - 1, i); | |
Console.Write('║'); | |
} | |
draw_ring(32, 22, "green"); | |
draw_ring(36, 22, "red"); | |
draw_ring(40, 22, "yellow"); | |
draw_ring(44, 22, "blue"); | |
draw_ring(48, 22, "cyan"); | |
for(i = 0; i < max_notes; i++) | |
{ | |
if(note[i].exists == true) | |
{ | |
switch(note[i].lane) | |
{ | |
case 1: Console.ForegroundColor = ConsoleColor.Green; break; | |
case 2: Console.ForegroundColor = ConsoleColor.Red; break; | |
case 3: Console.ForegroundColor = ConsoleColor.Yellow; break; | |
case 4: Console.ForegroundColor = ConsoleColor.Blue; break; | |
case 5: Console.ForegroundColor = ConsoleColor.Cyan; break; | |
}/*case*/ | |
Console.SetCursorPosition(note[i].x_coord-1, note[i].y_coord-1); | |
Console.Write(note_char); | |
Console.SetCursorPosition(0, 0); | |
} | |
} | |
Console.ForegroundColor = ConsoleColor.Black; | |
Console.SetCursorPosition(60-1, 6 - 1); | |
Console.WriteLine("Good: " + good); | |
Console.SetCursorPosition(60 - 1, 7 - 1); | |
Console.WriteLine("OK: " + ok); | |
Console.SetCursorPosition(60 - 1, 8 - 1); | |
Console.WriteLine("Miss: " + miss); | |
Console.SetCursorPosition(60 - 1, 13 - 1); | |
Console.WriteLine("Score: " + score); | |
Console.SetCursorPosition(60 - 1, 15 - 1); | |
Console.WriteLine("x" + score_multiplier); | |
Console.SetCursorPosition(60 - 1, 17 - 1); | |
Console.WriteLine('╔'); | |
for(i = 0; i < 5; i++) | |
{ | |
Console.SetCursorPosition(60 - 1, 17 + i); | |
Console.WriteLine('║'); | |
Console.SetCursorPosition(62 - 1, 17 + i); | |
Console.WriteLine('║'); | |
} /*for*/ | |
Console.SetCursorPosition(60 - 1, 23 - 1); | |
Console.WriteLine('╚'); | |
Console.SetCursorPosition(61 - 1, 17 - 1); | |
Console.WriteLine('═'); | |
Console.SetCursorPosition(61 - 1, 23 - 1); | |
Console.WriteLine('═'); | |
Console.SetCursorPosition(62 - 1, 17 - 1); | |
Console.WriteLine('╗'); | |
Console.SetCursorPosition(62 - 1, 23 - 1); | |
Console.WriteLine('╝'); | |
if(multiplier_count > 0) | |
{ | |
for(i = 0; i < multiplier_count; i++) | |
{ | |
switch(i + 1) | |
{ | |
case 1: Console.ForegroundColor = ConsoleColor.Green; break; | |
case 2: Console.ForegroundColor = ConsoleColor.Red; break; | |
case 3: Console.ForegroundColor = ConsoleColor.Yellow; break; | |
case 4: Console.ForegroundColor = ConsoleColor.Blue; break; | |
case 5: Console.ForegroundColor = ConsoleColor.Cyan; break; | |
} | |
Console.SetCursorPosition(61 - 1, 23 - (i + 1) - 1); | |
Console.Write('þ'); | |
} /*for*/ | |
} /*if*/ | |
} /*procedure drawgame*/ | |
static void game_move() | |
{ | |
if(count == note_gap) | |
{ | |
i = 0; | |
do | |
{ i++; } | |
while(note[i].exists != false); | |
note[i].exists = true; | |
note[i].lane = (short)(new Random().Next(5) + 1); | |
note[i].y_coord = 1; | |
switch(note[i].lane) | |
{ | |
case 1: note[i].x_coord = 32; break; | |
case 2: note[i].x_coord = 36; break; | |
case 3: note[i].x_coord = 40; break; | |
case 4: note[i].x_coord = 44; break; | |
case 5: note[i].x_coord = 48; break; | |
} /*case*/ | |
count = 0; | |
} /*if count=not_gap*/ | |
for(i = 0; i < max_notes; i++) | |
{ | |
if(note[i].exists == true) | |
note[i].y_coord++; | |
if(note[i].y_coord == 25) | |
{ | |
note[i].exists = false; | |
note[i].y_coord = 0; | |
miss++; | |
score_multiplier = 1; | |
multiplier_count = 0; | |
} | |
} | |
} /*procedure game_move*/ | |
static void get_input() | |
{ | |
input = Console.ReadKey(true).KeyChar; | |
for(number = 0; number < 5; number++) | |
{ | |
if(input == control[number]) | |
hit_check(number); | |
} | |
} /*get_input*/ | |
/* *** MAIN PROGRAM *** */ | |
static void Main(string[] args) | |
{ | |
Console.BackgroundColor = ConsoleColor.White; | |
Console.ForegroundColor = ConsoleColor.Black; | |
Console.Clear(); | |
//randomize; | |
score_multiplier = 1; | |
/* ** DIFFICULTY SETTINGS ** */ | |
/* "Hard" */ | |
delay_time = 125; | |
max_notes = 20; | |
note_gap = 2; | |
note_char = '*'; | |
score_gain_good = 100; | |
score_gain_ok = 50; | |
for(i = 0; i < 5; i++) | |
{ | |
Console.Clear(); | |
Console.WriteLine("Enter control for lane " + (i + 1)); | |
control[i] = Console.ReadKey(true).KeyChar; | |
} /*for*/ | |
do | |
{ | |
do | |
{ | |
System.Threading.Thread.Sleep(delay_time); | |
count++; | |
game_move(); | |
drawgame(); | |
} while(!Console.KeyAvailable); | |
get_input(); | |
} while(input != '='); | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment