1 RequireSystemScript("colors.js");
  2 RequireScript("Jest_Calc.js");
  3 RequireScript("Jest_Ball.js");
  4 RequireScript("Jest_Padl.js");
  5 RequireScript("Jest_Blck.js");
  6 RequireScript("Jest_Drop.js");
  7 RequireScript("Jest_Sound.js");
  8 
  9 var font = GetSystemFont();
 10 font.setColorMask(CreateColor(200,200,200,255))
 11 var font2 = GetSystemFont();
 12 font2.setColorMask(CreateColor(100,100,100,200))
 13 
 14 var S_bounce 	= LoadSoundEffect("bounce.wav", SE_MULTIPLE);
 15 var S_break 	= LoadSoundEffect("break.wav", SE_MULTIPLE);
 16 var S_crystal	= LoadSoundEffect("crystal.wav", SE_MULTIPLE);
 17 
 18 var randcd = 100;
 19 
 20 var score = 0;
 21 var lives = 4;
 22 var level = 1;
 23 var debug = false
 24 
 25 var balls = []
 26 var paddles = []
 27 var blocks = []
 28 var drops = []
 29 function game(){
 30 while(true){
 31 score = 0;
 32 lives = 4;
 33 level = 1;
 34 debug = false
 35 
 36 balls = []
 37 paddles = []
 38 blocks = []
 39 drops = []
 40 doitall()}
 41 }
 42 
 43 function drawHud(){
 44 Rectangle(0,0,GetScreenWidth(), 32, Blue)
 45 OutlinedRectangle(2, 2, GetScreenWidth()-3, 29, CreateColor(100,100,100,200))
 46 OutlinedRectangle(1, 1, GetScreenWidth()-3, 29, CreateColor(200,200,200,200))
 47 Line(0, 32, GetScreenWidth(), 32, CreateColor(200,200,200,200))
 48 Line(0, 33, GetScreenWidth(), 33, CreateColor(100,100,100,200))
 49 font2.drawText(11,11,"SCORE: " + score)
 50 font.drawText(10,10,"SCORE: " + score)
 51 
 52 font2.drawText(121,11,"LEVEL: " + level)
 53 font.drawText(120,10,"LEVEL: " + level)
 54 
 55 font2.drawText(211,11,"BLOCKS: "+blocks.length)
 56 font.drawText(210,10,"BLOCKS: "+blocks.length)
 57 
 58 font2.drawText(321,11,"LIVES: ")
 59 font.drawText(320,10,"LIVES: ")
 60 
 61 var i = 0;
 62 	while(i<lives){
 63 	FilledCircle(330+font.getStringWidth("LIVES: ")+18*i, 16, 8, White);
 64 	i++
 65 	}
 66 
 67 }
 68 
 69 var lasttrajmod = 0;
 70 
 71 
 72 function pause(){
 73 while(IsAnyKeyPressed()){}
 74 while(AreKeysLeft()){GetKey()}
 75 font2.drawZoomedText(112, 78, 2.3, "Jester's Breakout")
 76 font.drawZoomedText(110, 76, 2.3, "Jester's Breakout")
 77 
 78 font2.drawZoomedText(187, 178, 2.3, "PAUSED")
 79 font.drawZoomedText(185, 176, 2.3, "PAUSED")
 80 FlipScreen();
 81 
 82 while(!IsAnyKeyPressed()){}
 83 while(IsAnyKeyPressed()){}
 84 while(AreKeysLeft()){GetKey()}
 85 
 86 }
 87 
 88 function gameover(){
 89 while(IsAnyKeyPressed()){}
 90 while(AreKeysLeft()){GetKey()}
 91 font2.drawZoomedText(112, 78, 2.3, "Jester's Breakout")
 92 font.drawZoomedText(110, 76, 2.3, "Jester's Breakout")
 93 
 94 font2.drawZoomedText(167, 178, 2.3, "GAMEOVER")
 95 font.drawZoomedText(165, 176, 2.3, "GAMEOVER")
 96 FlipScreen();
 97 
 98 while(!IsAnyKeyPressed()){}
 99 while(IsAnyKeyPressed()){}
100 while(AreKeysLeft()){GetKey()}
101 
102 }
103 
104 
105 function doitall(){
106 
107 FlipScreen();
108 paddles.push(new paddle(0, GetScreenHeight()-48,GetScreenWidth(), Yellow));
109 titlescreen();
110 S_crystal.play();
111 while(AreKeysLeft()){GetKey()}
112 //As elegant as it is to see the screen as a set of blocks, it is slow.
113 //							block(x, 	y, 	hp,	drop, imageorheight, width, color)
114 //blocks.push(new block(64, 64, 1, new drop(96, 96, 1, LoadImage("bluepowerup.tga"),decrementballspeed), 					16, 	64, 		Red));
115 paddles[0] = new paddle(10, GetScreenHeight()-26,100, Yellow);
116 LoadLevel(level);
117 while(true){
118 if(blocks.length==0){level++; LoadLevel(Math.min(level, 3));}
119 var fips = GetTime();
120 processBlocks();
121 if(IsKeyPressed(KEY_P)){pause()}
122 processBalls();
123 processPaddles();
124 if(drops.length>0) {processDrops()}
125 drawHud();
126 randcd--;
127 
128 if(debug){
129 FilledCircle(GetMouseX(), GetMouseY(), 8, White);
130 Line(GetMouseX(), GetMouseY(), GetMouseX(), GetScreenHeight(), White);
131 var angle = -((1.1*(Math.PI/2))-((Math.PI/2)*(paddles[0].gettrajmod(new theorypoint(GetMouseX(), GetMouseY()))/2)))
132 Line(GetMouseX(), GetScreenHeight(), GetMouseX()+Math.cos(angle)*100, GetScreenHeight()+Math.sin(angle)*100, White); 
133 
134 }
135 
136 
137 FlipScreen();
138 soundHK();
139 if(lives==0){
140 gameover();
141 return "";
142 }
143 do{}while(fips+30>GetTime())
144 }
145 
146 
147 }
148