Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AxesOff
- 84→Xmin
- 72→Ymax
- ZInteger //golfed initialization of the graph screen to square coordinates
- 1→C //starting Dalek count
- Repeat C>9 //Levels 1-9 will run with 2-10 Daleks
- binomcdf(C,0→L₃ //Fill a C+1 long list of 1s for whether each Dalek is alive. On OS 1.02, binomcdf appears to work differently and 0 needs to be 1.
- C+1→C //Increment the number of Daleks each level, placing it here to avoid C-1 in the previous function
- 1+3int(31rand(Ans→L₁ //coordinate placement for Dalek enemies. rand(c sets a list of C random numbers, then the list is transformed into 3 pixel wide coordinates for the graph screen
- 1+3int(21rand(C→L₂
- Repeat not(sum(X=L₁ and Ans=L₂ //place the doctor on the grid using A and B for X and Y coordinates, and make sure he doesn't start on a Dalek
- 1+3int(31rand→X
- 1+3int(21rand→B
- End
- 1→S //S is 1 until the Sonic Screwdriver is used
- While sum(L₃ //repeat the loop within the level while some Daleks are still alive
- Pt-On(X,B,3 //draw the doctor's sprite
- For(D,1,C
- Pt-On(L₁(D),L₂(D),2 //draw the dalek sprites
- End
- Repeat Ans //look for a keypress until one has happened. Repeat loops go once before checking conditions, so Ans always has a chance to become the value of getKey
- rand //spurious rand call to aid RNG manip in TAS
- getKey→G //store the last key code to G
- End
- Pt-Off(X,B,3 //delete the doctor's current sprite using pt mode 3 to draw a +
- If S(Ans=81 //Use the sonic screwdriver if it hasn't been used yet and the Ln key was pressed (above store)
- DelVar SL₃not(4>abs(L₁-X) and 4>abs(L₂-B→L₃ //Note the use of the screwdriver and kill Daleks that are directly adjacent to the doctor. DeMorgan's laws can flip how this is done, haven't tested which way is faster yet, not( allows for implicit multiplication
- If G=91 //if the store key is pressed, use the Tardis (moves somewhere on the grid randomly, including dangerous places)
- Then
- 1+3int(31rand→X
- 1+3int(21rand→B
- End
- min(91,max(1,X+3(max(G={74,84,94})-max(G={72,82,92→X //golfed movement code for the Doctor using the numpad
- min(61,max(1,B+3(max(G={72,73,74})-max(G={92,93,94→B
- For(D,1,C) //loop through the Daleks to clear their current sprites
- If L₃(D //If the dalek is alive
- Pt-Off(L₁(D),L₂(D),2 //Clear the current sprite using pt-off mode 2 to delete a square
- End
- L₁+L₃3((L₁<X)-(L₁>X→L₁ //Move all daleks toward the doctor. This code can be 10 bytes shorter using a trick with tanh(E9X to pull the sign of X, but it runs slower.
- L₂+L₃3((L₂<B)-(L₂>B→L₂
- If sum(X=L₁ and B=Ans //if the character's coordinates are equal to both of any of the Dalek's locations
- Then
- Text(28,32,"YOU DIED //Stop the game and tell the player they died
- Stop
- End
- For(D,1,C) //We have to do 2 separate loops so that all daleks move before locations are checked for dalek collision
- L₃(D)=sum(L₁=L₁(D) and L₂=L₂(D→L₃(D //Mark daleks as dead if there are multiple in the same place, keeping them dead if they already are
- If not(Ans //If the current dalek is dead
- Pt-On(L₁(D),L₂(D //Mark its death by filling in the dalek's sprite
- End
- End
- V+C→V //update the score for winning the round
- ClrDraw
- Text(28,40,"SCORE:",Ans //Draw the score between rounds
- Pause
- ClrDraw
- End
- Text(28,32,"YOU WON
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement