SimplySudoku

From Hack Wars Wiki

Jump to: navigation, search

Simply Sudoku is a sudoku game created by Surfpup. Surfpup has also created one original puzzle from scratch for this game.

Initialize

//changeMap(0,1);
setGlobal("screenTextTime", "false");
setGlobal("screenTextB", 0);
setGlobal("screenTextContent", "");
setGlobal("page", "main");
setGlobal("addsquaren", 0);
setGlobal("squarex", 0);
setGlobal("squarey", 0);
setGlobal("highlighted", -1);
setGlobal("thepuzzle", "");
setGlobal("wrong", 0);
setGlobal("correctn", 0);
setGlobal("puzzlenum", 0);
setGlobal("puzzlediff", 2);
setGlobal("succeeded", "");
setGlobal("Auto-fill", "");
setGlobal("movedowny", 10);
setGlobal("moveleftx", -35);
setGlobal("found", 0);
setGlobal("failed", 0);


Continue

void main() {
	setViewportY(30);
	setViewportX(30);
	int movedowny=getGlobal("movedowny");
	int moveleftx=getGlobal("moveleftx");
	string page=getGlobal("page");
	int squarey=getGlobal("squarey");
	int squarex=getGlobal("squarex");
	int highlighted=0;
	highlighted=squarey*9; highlighted=highlighted+squarex+1; setGlobal("highlighted", highlighted);
	if (page=="main") {
		drawText("Surfpup presents","Lucida Console",10,10,15,255,200,0,255);
		drawText("Simply Sudoku","Lucida Console",20,70,45,0,255,255,255);
		string toshow="Difficulty:"+char(10)+char(10)+"1: Easy (3 Puzzles)"+char(10)+char(10)+"3: Hard (1 Puzzle)";
		screenText(toshow,strlen(toshow),110,90);
		drawText("Instructions:","Lucida Console",10,80,160,255,255,255,255);
		drawText("Use arrows to move;","Lucida Console",10,60,180,255,255,255,255);
		drawText("To input possible solutions into a square,","Lucida Console",10,0,190,255,255,255,255);
		drawText("press enter, then press number(s), then press","Lucida Console",10,0,200,255,255,255,255);
		drawText("enter again to go back to normal mode","Lucida Console",10,0,210,255,255,255,255);
			int downcount=getKeyDownCount();
			string add="";
			if(downcount>0) {
				int key=getNextKeyDown();
				string adding=getGlobal("addingPossibilities");
				if (key==49) {
					setGlobal("puzzlenum", 0); setGlobal("puzzlediff",0);
					setGlobal("page", "game");
				}
				/*if (key==50) {
					setGlobal("puzzlenum", 0); setGlobal("puzzlediff",1);
					setGlobal("page", "game");
				}*/
				if (key==51) {
					setGlobal("puzzlenum", 0); setGlobal("puzzlediff",2);
					setGlobal("page", "game");
				}
			}
 
	}
	if (page=="game") {
		if (getGlobal("puzzletime")!="true") { createTimeStamp("puzzle"); setGlobal("puzzletime", "true"); }
		//drawText("Simply Sudoku","Lucida Console",20,60,15,0,200,200,255);
		drawRectangle(39+getGlobal("moveleftx"),19+getGlobal("movedowny"),203,203,255,0,0,255);
		drawRectangle(40+getGlobal("moveleftx"),20+getGlobal("movedowny"),203,203,255,0,0,255);
		drawRectangle(41+getGlobal("moveleftx"),21+getGlobal("movedowny"),203,203,255,0,0,255);
		//fillRectangle(43,23,197,197,152,245,255,255);
		int y=22+getGlobal("movedowny"); int b=0; int x=42+getGlobal("moveleftx"); int c=0;
		while(b<9) {//127;255;212
			drawRectangle(x-1,y-1,67,67,127,255,212,255);
			drawRectangle(x,y,67,67,127,255,212,255);
			drawRectangle(x+1,y+1,67,67,127,255,212,255);
			x=x+66;
			b++; c++;
			if (c==3) { y=y+66; x=42+getGlobal("moveleftx"); c=0; }
		}
		int puzzdiff=getGlobal("puzzlediff");
		int puzznumber=getGlobal("puzzlenum");
		int complete=0;
		//string checky="succeeded";
		if (getGlobal("correctn")==81) {
			complete=1;
			drawText("SUCCESS","Lucida Console",65,5,120,255,255,0,255);
			if (getGlobal("succeeded")=="") { createTimeStamp("succeeded"); setGlobal("succeeded", "true!"); }
			if (getGlobal("succeeded")!="") {
				if (checkTimeStamp("succeeded") > 2000) {
 
		int time=checkTimeStamp("puzzle");
		int seconds=time/1000;
		seconds=seconds-2;
		int minutes=seconds/60;
		int bla=minutes*60;
		seconds=seconds-bla;
		string sec=seconds+"";
		if (seconds<10) sec="0"+sec;
				setGlobal("successtime", minutes+":"+sec);
				deleteTimeStamp("puzzle");
 
					deleteTimeStamp("succeeded");
					setGlobal("succeeded", "");
					setGlobal("correctn", 0);
					setGlobal("wrong", 0);
					setGlobal("puzzlenum", getGlobal("puzzlenum")+1);
					puzznumber++;
					setGlobal("Auto-fill", "");
					createTimeStamp("puzzle");
				}
			}
		}
		string thediff="";
		int amtcorrect=getGlobal("correctn");
		if (puzzdiff==0) thediff="Easy";
		if (puzzdiff==1) thediff="Medium";
		if (puzzdiff==2) thediff="Hard";
		drawText("Difficulty: "+thediff,"Lucida Console",12,10,10,255,255,0,255);
		drawText("Puzzle: "+puzznumber,"Lucida Console",12,200,10,255,255,0,255);
		drawText("Errors: "+getGlobal("wrong")+"/3","Lucida Console",10,210,40,255,255,0,255);
		int time=checkTimeStamp("puzzle");
		int seconds=time/1000;
		int minutes=seconds/60;
		int bla=minutes*60;
		seconds=seconds-bla;
		string sec=seconds+"";
		if (seconds<10) sec="0"+sec;
		drawText("Time: "+minutes+":"+sec,"Lucida Console",10,210,60,255,255,0,255);
		//puzzle(0,-1);
		puzzle(puzzdiff,puzznumber);
		if (getGlobal("wrong")>=3 && complete==0) {
			if (getGlobal("failed")=="") { createTimeStamp("failed"); setGlobal("failed", "true!"); }
			if (getGlobal("failed")!="") {
				if (checkTimeStamp("failed") > 3000) {
					setGlobal("wrong",0); 
					for(int h=0;h<81;h++) { setGlobal("add"+h, ""); setGlobal("correct-"+h, ""); }
					deleteTimeStamp("failed");
					setGlobal("failed", "");
					deleteTimeStamp("puzzle");
					createTimeStamp("puzzle");
				}
			}
			drawText("EPIC","Lucida Console",80,50,100,255,0,0,255);
			drawText("FAIL","Lucida Console",80,50,170,255,0,0,255);
		}
		if (getGlobal("wrong")<3 && complete==0 && puzznumber>-1) {
			int downcount=getKeyDownCount();
			string add="";
			if(downcount>0) {
				int key=getNextKeyDown();
				string adding=getGlobal("addingPossibilities");
				if (key==37) { //left
					if (squarex>0) {
						if (adding!="true") squarex--; setGlobal("squarex", squarex);
					}
				}
				if (key==39) { //right
					if (squarex<8) {
						if (adding!="true") squarex++; setGlobal("squarex", squarex);
					}
				}
				if (key==40) { //down
					if (squarey<8) {
						if (adding!="true") squarey++; setGlobal("squarey", squarey);
					}
				}
				if (key==38) { //up
					if (squarey>0) {
						if (adding!="true") squarey--; setGlobal("squarey", squarey);
					}
				}
				if (key>=49 && key<=57)	{
					highlighted=squarey*9; highlighted=highlighted+squarex; 
					if (adding!="true") {
						if (getGlobal("correct-"+highlighted)!="true") setGlobal("add"+highlighted, char(key));
					}
					if (adding=="true") {
						string check=getGlobal("possible-"+char(key)+"-"+highlighted);
						if (check=="") setGlobal("possible-"+char(key)+"-"+highlighted, char(key));
						if (check!="") setGlobal("possible-"+char(key)+"-"+highlighted, "");
					}
				}
				if (key==88) { setGlobal("Auto-fill", "true"); }
				if (key==10) { 
					if (adding!="true") {
						highlighted=squarey*9; highlighted=highlighted+squarex; 
						if (getGlobal("correct-"+highlighted)!="true") setGlobal("addingPossibilities", "true");
					}
					if (adding=="true") setGlobal("addingPossibilities", "false");
				}
 
			}
		}
	}
}
void puzzle(int difficulty, int puzzlen) {
	if (difficulty==0) {
		if (puzzlen==0) {
			int display[]={0,0,4,5,0,0,0,0,9,6,2,0,7,0,0,0,5,3,0,5,0,4,3,1,0,8,0,0,0,9,8,0,0,0,0,1,5,3,0,0,0,0,0,9,4,2,0,0,0,0,4,7,0,0,0,4,0,1,9,2,0,6,0,7,6,0,0,0,5,0,1,8,1,0,0,0,0,8,2,0,0};
			int answerkey[]={3,8,4,5,2,6,1,7,9,6,2,1,7,8,9,4,5,3,9,5,7,4,3,1,6,8,2,4,7,9,8,6,3,5,2,1,5,3,6,2,1,7,8,9,4,2,1,8,9,5,4,7,3,6,8,4,5,1,9,2,3,6,7,7,6,2,3,4,5,9,1,8,1,9,3,6,7,8,2,4,5};
			writePuzzle(display, answerkey);
		}
		if (puzzlen==1) {
			int answerkey[]={3,9,8,4,1,7,2,5,6,5,4,7,3,2,6,9,1,8,6,1,2,9,8,5,3,7,4,1,2,3,5,6,4,7,8,9,9,6,5,8,7,1,4,3,2,7,8,4,2,9,3,1,6,5,4,5,9,1,3,8,6,2,7,8,7,1,6,4,2,5,9,3,2,3,6,7,5,9,8,4,1};
			int display[]={0,9,0,0,0,0,2,0,6,0,4,7,0,2,0,0,1,8,0,0,0,9,8,5,0,0,0,1,2,3,0,0,4,7,0,0,9,0,0,8,0,1,0,0,2,0,0,4,2,0,0,1,6,5,0,0,0,1,3,8,0,0,7,8,7,0,0,4,0,5,9,0,2,0,6,0,0,9,0,4,0};
			//setGlobal("thepuzzle",display);
			writePuzzle(display, answerkey);
		}
		if (puzzlen==2) {
			int answerkey[]={2,9,7 , 8,5,4 , 6,1,3 , 
					6,5,1 , 3,7,9 , 4,8,2 , 
					8,4,3 , 2,1,6 , 5,9,7 ,
 
					4,1,8 , 9,6,3 , 7,2,5 , 
					3,7,9 , 1,2,5 , 8,6,4 , 
					5,2,6 , 4,8,7 , 1,3,9 , 
 
					9,6,2 , 7,4,1 , 3,5,8 , 
					7,8,5 , 6,3,2 , 9,4,1 , 
					1,3,4 , 5,9,8 , 2,7,6};
			int display[]={ 2,0,0 , 0,0,4 , 0,1,3 , 
					0,5,0 , 3,0,9 , 0,0,2 , 
					8,4,0 , 0,1,6 , 0,0,0 ,
 
					0,1,8 , 0,6,3 , 7,0,0 , 
					3,0,9 , 0,0,0 , 8,0,4 , 
					0,0,6 , 4,8,0 , 1,0,0 , 
 
					0,0,2 , 7,4,0 , 0,5,8 , 
					7,0,0 , 6,0,2 , 0,4,0 , 
					1,3,0 , 5,0,0 , 0,0,6};
			//setGlobal("thepuzzle",display);
			writePuzzle(display, answerkey);
		}
	}
	if (difficulty==2) {
		if (puzzlen==0) { //My First Puzzle
			int answerkey[]={1,8,9 , 3,5,4 , 7,2,6 , 7,2,5 , 9,1,6 , 4,8,3 , 3,6,4 , 7,8,2 , 5,9,1 , 8,5,3 , 1,4,7 , 9,6,2 , 9,7,6 , 5,2,3 , 1,4,8 , 4,1,2 , 8,6,9 , 3,5,7 , 5,4,8 , 6,3,1 , 2,7,9 , 2,9,1 , 4,7,8 , 6,3,5 , 6,3,7 , 2,9,5 , 8,1,4};
			int display[]={ 0,8,0 , 3,0,0 , 0,2,0 , 7,0,0 , 0,0,0 , 4,0,3 , 0,6,0 , 7,0,2 , 0,9,0 , 8,0,0 , 0,4,0 , 0,0,2 , 0,0,6 , 5,0,3 , 1,0,0 , 0,0,2 , 0,6,0 , 3,0,0 , 0,4,0 , 6,0,1 , 0,7,0 , 2,0,1 , 0,0,0 , 0,0,5 , 0,3,0 , 0,0,5 , 0,1,0};
			writePuzzle(display, answerkey);
		}
	}
}
void writePuzzle(int puzzledata[], int answers[]) {
	int y1=24+getGlobal("movedowny"); int x1=43+getGlobal("moveleftx");// int c=0; int d=0;
	int y=40+getGlobal("movedowny"); int b=0; int x=50+getGlobal("moveleftx"); int c=0; int d=0;
	int e=0;
	int amtcorrect=0;
	int wrong=0;
	string puzchar="";
	string anschar="";
	while(b<81) {
		int red=255; int green=255; int blue=255;
		puzchar=puzzledata[b]+"";
		anschar=answers[b]+"";
string poss=getGlobal("possible-1-"+b)+getGlobal("possible-2-"+b)+getGlobal("possible-3-"+b);
string poss2=getGlobal("possible-4-"+b)+getGlobal("possible-5-"+b)+getGlobal("possible-6-"+b);
string poss3=getGlobal("possible-7-"+b)+getGlobal("possible-8-"+b)+getGlobal("possible-9-"+b);
string tposs=poss+poss2+poss3;
 
		if (puzchar=="0") puzchar="";
		if (getGlobal("Auto-fill")=="true") { puzchar=anschar; amtcorrect++; setGlobal("correctn",amtcorrect); }
		if (getGlobal("Auto-fill")!="true") {
		if (puzchar==anschar) { unsettingGlobals(b); amtcorrect++; setGlobal("correctn",amtcorrect); setGlobal("correct-"+b, "true"); }
		if (puzchar=="") {
			if (getGlobal("add"+b)!="") {
				puzchar=getGlobal("add"+b);
				if (puzchar==anschar) {
					red=0; green=255; blue=0;
					if (getGlobal("wrong"+b)!="") setGlobal("wrong"+b, "");
					amtcorrect++; setGlobal("correctn",amtcorrect);
					setGlobal("correct-"+b, "true");
					unsettingGlobals(b);
				}
				if (puzchar!=anschar) {
					red=255; green=0; blue=0;
					//wrong++;
					if (getGlobal("wrong"+b)!=puzchar) { 
						setGlobal("wrong", getGlobal("wrong")+1);
						setGlobal("wrong"+b, puzchar+"");
					}
				}
			}
		}
		}
		int scR=0;
		int scG=0;
		int scB=129;
		if (e==getGlobal("squarey") && c==getGlobal("squarex")) { 
			fillRectangle(x1+1,y1+1,20,20,0,255,255,150);
			if (getGlobal("addingPossibilities")=="true") { 
				drawOval(x1+1,y1+1,20,20,255,255,255,200);
			}
		}
		drawRectangle(x1,y1,21,21,scR,scG,scB,255);
		drawText(puzchar,"Lucida Console",15,x,y,red,green,blue,255);
 
		drawText(poss,"Lucida Console",8,x-5,y-9,0,255,255,255);
		drawText(poss2,"Lucida Console",8,x-5,y-2,0,255,255,255);
		drawText(poss3,"Lucida Console",8,x-5,y+5,0,255,255,255);
 
		x=x+21; x1=x1+21;
		b++; c++; 
		if (c==3 || c==6 || c==9) { x=x+4; x1=x1+4; }
		if (c==9) { 
			y1=y1+21; x1=43+getGlobal("moveleftx");
			y=y+21; x=50+getGlobal("moveleftx"); c=0; d++; e++;
			if (d==3) { y=y+3; y1=y1+3; d=0; }
		}
	}
	//drawText("Correct: "+amtcorrect,"Lucida Console",12,120,20,255,255,0,255);
}
void screenText(string text, int stop, int x, int y) {
	if (getGlobal("screenTextTime")!="true") {
		setGlobal("screenTextB", 0);
		setGlobal("screenTextContent", "");
		createTimeStamp("screenText"); setGlobal("screenTextTime", "true");
	}
	int bb=0;
	int aa=getGlobal("screenTextB");
	int checkit=checkTimeStamp("screenText");
	if (aa<strlen(text) && aa<=stop) {
		if (checkit>=20) { setGlobal("screenTextB", aa+1); aa++; }
	}
int line=1;
string thechar="";
int oldbb=0;
 
	while (bb<aa && bb<stop) {
		oldbb=bb;
		bb=indexOf(text, char(10), bb+1);
		if (bb==-1 || bb>aa) bb=aa;
		drawText(substr(text, oldbb, bb),"Lucida Console",10,x,y,255,255,255,255);
		line++;
		y=y+10;
	}
	//lastline=y;
}
Personal tools