Invaders-9850 v0.9b (beta version) (c) Hidetake Jo 1996 ***This page is for people who want to understand my messy code*** ----------------------------------------------------------------- For those of you who want to make "some" sense out of my messy code read the comments below. The code is really messy, and it's really not the place to look for to learn programming, but for those who are curious enough to peek into my unorganized, inefficient, and messy code, go right on ahead :-) Happy Coding! -Hidetake Jo :-) (hjo@engin.umich.edu) ----------------------------------------------------------------- {-------> Use Cls to clean the screen <----------------------------------------} Cls {-------> Use ViewWindow to set the range of the window <----------------------} {-------> In this case I set the range as the following <----------------------} {-------> X axis minimum is one, x axis maximum is 126 and scale is one<-------} {-------> y axis minimum is one, y axis maximum is 64 and scale is one<--------} ViewWindow 1, 126, 1, 1, 64, 1 {-------> Assign the value zero to variables A through Z<----------------------} 0->A~Z {-------> Print the words INVADERS in the location 20, 45<---------------------} {-------> the syntax for Text command is: text, yvalue, xvalue, "Sentence"----} Text 20, 45, "INVADERS" {-------> Make the words "PUSH EXE" blink until the player preses EXE<---------} {-------> This works like this: GetKey returns a value when ever a user<------} {-------> pushes a button, and the value of [EXE] is 31 there for I told the<--} {-------> calculator to keep on replacing the words "PUSH EXE" and the<---------} {-------> and the blank spaces until the user pushes EXE <---------------------} While GetKey =/= 31 Text 30, 42, "PUSH [EXE]" Text 30, 42, " " WhileEnd Cls {--------------> P is the X location of the player-----------------------------} 50->P {-----> Z decides if the game is over or not, will explain in a minute<-------} 1->Z {------> Assign value of one to variables G through I hence G, H, I<----------} {------> Each letter represents a sprite, and while the letter has the <-------} {------> value of "one" it can keep on moving and shooting<--------------------} {------> When it dies, it get's a value of "zero" <---------------------------} 1->G~I {-------> speed at which the enemies move<------------------------------------} 15->J {-----> Arbituary location of the sprite, this one value determines the<------} {-----> location of 3 other sprites<------------------------------------------} 10->A {-----> value of y coordinate of the enemy sprites<---------------------------} 60->B {-------> This is the main loop of the program, the program<------------------} {-------> keeps on running while the value of Z is "one"<---------------------} {-------> when you die the value of Z becomes "0"<----------------------------} {-------> when you win the value of Z becomes "2"<----------------------------} While Z=1 {-------> Loop 3 times to draw 3 sprites<-------------------------------------} For 1->C To 3 {-------> if sprite number one is dead don't draw him<-------------------------} C=1 => G=0 =>Goto 1 {-------> if sprite number two is dead don't draw him<-------------------------} C=2 => H=0 =>Goto 1 {-------> if sprite number three is dead don't draw him<-----------------------} C=3 => I=0 =>Goto 1 {-------> Some stupid calculation to space out the sprites<--------------------} A+4C->D {-------> If the value of N is 777 it means that one of the enemies<-----------} {-------> is already shooting. If none of the enemies are shooting<----------} {-------> then randomiz e a number1 through 5<---------------------------------} N =/= 777 =>Int 5Ran#+1->E {-------> if the randomized number is 3 and no enemies are shooting yet<-------} If (E=3) And (N =/= 777) {->Then assign the value of 777 to N so to prevent other enemies from shooting-} Then 777->N {-------> store current location of "x" of shooting sprite in "M"<-------------} {------->M will be used later for the "x" location of the shot<----------------} D->M {------->Set inital location "y" of the shot<----------------------------------} 60->O IfEnd {-------> reusable code below, for drawing 3 sprites<--------------------------} PlotOn D,B PlotOn D+1,B PlotOn D,B+1 PlotOn D+1,B+1 PlotOff D-J, B PlotOff D-(J-1), B PlotOff D-J, B+1 PlotOff D-(J-1), B+1 {------->This is where Goto 1 skips to if one of the sprite is dead<----------} Lbl 1 {------->Below command executes if one of the enemy is shooting"<-------------} If N=777 Then PlotOn M, O PlotOff M, O+10 O-10->O {-------> checks to see if the shot killed the player<------------------------} O < 11 => M > P-1 => M < P+6 => 0->Z {------->removes shot if out of screen<---------------------------------------} O =< -3 => 0->N IfEnd {-------> Below command executes if player is shooting<-----------------------} If V=777 Then PlotOn W, R PlotOff W, R-10 R+10->R {------->Below commands check to see if it has shot any enemies<--------------} If (R>49) And (R <66) Then W>A+3 => W 0->G W>A+7 => W 0->H W>A+11 => W 0->I IfEnd {-------> removes player shot if it goes out of screen<-----------------------} R > 64 => 0->V IfEnd {-------> draw player<--------------------------------------------------------} Text 55, P, "O" {-------> if left arrow is pressed the below commands execute<----------------} If GetKey=38 Then P-10->P P < 24 =>P+10->P Text 55, P, "O" Text 55, P+10, " " IfEnd {-------> if right arrow is pressed the below commands execute<---------------} If GetKey=27 Then P+10->P P < 24 =>P-10->P Text 55, P, "O" Text 55, P-10, " " IfEnd {-------> if up arrow is pressed and previous shot is nonexistant<------------} {-------> the commands below execute<-----------------------------------------} If (GetKey=28) And (V =/= 777) Then P->W 777->V 10->R IfEnd {------->ends the "for" loop here<--------------------------------------------} Next {------->below 2 lines make sure the enemies stay in screen<------------------} {-------> by chaging velocity from postive to negative and vice versa<--------} D+14>109=>-15->J D<16=>15->J {-------> changes enemy location<---------------------------------------------} A+J->A {------->Below 3 lines are just a stupid routine to clean<--------------------} {------->the screen every once ina while to prevent junk<---------------------} {------->to be left onthe screen<---------------------------------------------} T+1->T T>5 => Text 2, 5, " " {21 spaces here} T>5=>0->T {-------> if all enemies are dead end game with Z value of 2<-----------------} G=0 => H=0 => I=0 => 2->Z WhileEnd {------->Ending message<------------------------------------------------------} Z=0 => Text 20, 45, "GAME OVER" Z=2 => Text 20, 45, "YOU WIN"