PureBasic 5.62 (Windows - x64)
Feel the ..Pure.. Power
I was trying to compile an old progrm I wrote a long time ago to avoid boredom: Maybe someone else can run it. It is my own interpretation of Tetrus, which means "four" In Russian.
Code: Select all
; Author: Randy Walker (updated for PB 4.00)
; Date: January 2010
; OS: Windows
; Program name: Fourski
Procedure pretest()
If InitSprite() = 0
MessageRequester("Error", "Can't open screen & sprite enviroment!", 0)
End
EndIf
Global scard.l, sfx.l
sfx.l = #True
If InitSound() = 0
MessageRequester("Error", "Can't open DirectX 7 or no sound card is available", 0)
scard.l = #False
sfx.l = #False
EndIf
If sfx = #True
scard.l = #True
;Stepdown
If LoadSound(0, "C:\WINDOWS\Media\Windows XP Menu Command.wav")
Else
Debug "missed 0"
scard.l = #False
sfx.l = #False
EndIf
;Left / Right
If LoadSound(1, "C:\WINDOWS\Media\Windows XP Start.wav")
Else
Debug "missed 1"
scard.l = #False
sfx.l = #False
EndIf
;Rotate
If LoadSound(2, "C:\WINDOWS\Media\Windows XP Start.wav")
Else
Debug "missed 2"
scard.l = #False
sfx.l = #False
EndIf
;Drop
If LoadSound(3, "C:\WINDOWS\Media\Windows XP Minimize.wav")
Else
Debug "missed 3"
scard.l = #False
sfx.l = #False
EndIf
;Score
If LoadSound(4, "C:\WINDOWS\Media\Windows XP Hardware Fail.wav")
Else
Debug "missed 4"
scard.l = #False
sfx.l = #False
EndIf
;Pee break
If LoadSound(5, "C:\WINDOWS\Media\Windows XP Hardware Remove.wav")
Else
Debug "missed 5"
scard.l = #False
sfx.l = #False
EndIf
;Pee return
If LoadSound(6, "C:\WINDOWS\Media\Windows XP Hardware Insert.wav")
Else
Debug "missed 6"
scard.l = #False
sfx.l = #False
EndIf
If sfx = #False
MessageRequester("Error", "One or more Windows XP sound files is missing.", 0)
EndIf
EndIf
EndProcedure
Procedure initdata()
DataSection
;; ;; FFFFFFFFFFF
Data.w 5,45
Data.w 5,60
Data.w 5,75
Data.w 5,90
Data.w 5,105
Data.w 5,120
Data.w 5,135
Data.w 5,150
Data.w 5,165
Data.w 20,45
Data.w 35,45
Data.w 50,45
Data.w 65,45
Data.w 20,105
Data.w 35,105
Data.w 50,105
;; ;; OOOOOOOOOOO
Data.w 105,45
Data.w 105,60
Data.w 105,75
Data.w 105,90
Data.w 105,105
Data.w 105,120
Data.w 105,135
Data.w 105,150
Data.w 105,165
Data.w 120,45
Data.w 135,45
Data.w 150,45
Data.w 105,165
Data.w 120,165
Data.w 135,165
Data.w 150,165
Data.w 165,45
Data.w 165,60
Data.w 165,75
Data.w 165,90
Data.w 165,105
Data.w 165,120
Data.w 165,135
Data.w 165,150
Data.w 165,165
;; ;; UUUUUUUUUUU
Data.w 205,45
Data.w 205,60
Data.w 205,75
Data.w 205,90
Data.w 205,105
Data.w 205,120
Data.w 205,135
Data.w 205,150
Data.w 205,165
Data.w 205,165
Data.w 220,165
Data.w 235,165
Data.w 250,165
Data.w 265,45
Data.w 265,60
Data.w 265,75
Data.w 265,90
Data.w 265,105
Data.w 265,120
Data.w 265,135
Data.w 265,150
Data.w 265,165
;; ;; RRRRRRRRRR
Data.w 305,45
Data.w 305,60
Data.w 305,75
Data.w 305,90
Data.w 305,105
Data.w 305,120
Data.w 305,135
Data.w 305,150
Data.w 305,165
Data.w 320,45
Data.w 335,45
Data.w 350,45
Data.w 350,60
Data.w 350,90
Data.w 320,105
Data.w 335,105
Data.w 350,105
Data.w 365,60
Data.w 365,75
Data.w 365,90
Data.w 335,120
Data.w 335,135
Data.w 350,135
Data.w 350,150
Data.w 365,150
Data.w 365,165
;; ;; SSSSSSSSSSSS
Data.w 420,45
Data.w 420,60
Data.w 405,60
Data.w 405,75
Data.w 405,90
Data.w 420,90
Data.w 435,45
Data.w 450,45
Data.w 450,60
Data.w 465,60
Data.w 465,75
Data.w 435,90
Data.w 435,105
;;Data 435,120
Data.w 450,105
Data.w 450,120
Data.w 465,120
Data.w 465,135
Data.w 465,150
Data.w 405,135
Data.w 405,150
Data.w 420,150
Data.w 420,165
Data.w 435,165
Data.w 450,165
Data.w 450,150
;; ;; KKKKKKKKKKKKKKK
Data.w 505,45
Data.w 505,60
Data.w 505,75
Data.w 505,90
Data.w 520,90
Data.w 520,105
Data.w 550,60
Data.w 550,75
Data.w 535,75
Data.w 535,90
Data.w 535,105
Data.w 535,120
Data.w 550,120
Data.w 550,135
Data.w 550,150
Data.w 565,150
Data.w 565,165
Data.w 505,105
Data.w 505,120
Data.w 505,135
Data.w 505,150
Data.w 505,165
;; ;; IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
Data.w 605,45
Data.w 605,60
Data.w 605,75
Data.w 605,90
Data.w 605,105
Data.w 605,120
Data.w 605,135
Data.w 605,150
Data.w 605,165
;; ;; ++++++++++++
Data.w 395,225
Data.w 410,225
Data.w 410,210
Data.w 410,240
Data.w 425,225
EndDataSection
EndProcedure
Procedure SetGlobals()
Global T.l, settled.l
Global k.l, GameBoard.l
Global l.l, beginner.l
Global r.l
Global d.l
Global bN.l
Global bR.l
Global bL.l
Global bH.l
Global A$
Global Pb$
Global c.l
Global x.l
Global x1.l
Global y.l
Global y1.l
Global score.l
Global speed.l
Global key.l
Global wait.l
Global Shape.l
;; bN.l-block#, bR.l-block rotation, bL.l-block latitude, bH.l-block height
;; lb|( type, x, y, rotation )
Global Dim l.l(20,43)
Global Dim Lb.l(7,4,4,4)
Global Dim Pb$(7,4)
Global Dim r.l(9)
Global Dim T.l(4)
EndProcedure
SetGlobals()
Declare grabNext4()
Procedure Original_init_logic()
;;___________________________________________
Lb(1,1,3,1) = 1 ;; : : Clockwise rotation
Lb(1,2,3,1) = 1
Lb(1,1,4,1) = 1
Lb(1,2,4,1) = 1
Lb(1,1,3,2) = 1
Lb(1,2,3,2) = 1
Lb(1,1,4,2) = 1
Lb(1,2,4,2) = 1
Lb(1,1,3,3) = 1
Lb(1,2,3,3) = 1
Lb(1,1,4,3) = 1
Lb(1,2,4,3) = 1
Lb(1,1,3,4) = 1
Lb(1,2,3,4) = 1
Lb(1,1,4,4) = 1
Lb(1,2,4,4) = 1
;;___________________________________________
Lb(2,1,4,1) = 1 ;; - - - -
Lb(2,2,4,1) = 1
Lb(2,3,4,1) = 1
Lb(2,4,4,1) = 1
Lb(2,1,1,2) = 1
Lb(2,1,2,2) = 1
Lb(2,1,3,2) = 1
Lb(2,1,4,2) = 1
Lb(2,1,4,3) = 1
Lb(2,2,4,3) = 1
Lb(2,3,4,3) = 1
Lb(2,4,4,3) = 1
Lb(2,1,1,4) = 1
Lb(2,1,2,4) = 1
Lb(2,1,3,4) = 1
Lb(2,1,4,4) = 1
;;___________________________________________
Lb(3,1,4,1) = 1 ;; ___|
Lb(3,2,4,1) = 1
Lb(3,3,4,1) = 1
Lb(3,3,3,1) = 1
Lb(3,2,4,2) = 1
Lb(3,1,4,2) = 1
Lb(3,1,3,2) = 1
Lb(3,1,2,2) = 1
Lb(3,1,4,3) = 1
Lb(3,1,3,3) = 1
Lb(3,2,3,3) = 1
Lb(3,3,3,3) = 1
Lb(3,1,2,4) = 1
Lb(3,2,2,4) = 1
Lb(3,2,3,4) = 1
Lb(3,2,4,4) = 1
;;___________________________________________
Lb(4,1,3,1) = 1 ;; |___
Lb(4,1,4,1) = 1
Lb(4,2,4,1) = 1
Lb(4,3,4,1) = 1
Lb(4,2,2,2) = 1
Lb(4,1,2,2) = 1
Lb(4,1,3,2) = 1
Lb(4,1,4,2) = 1
Lb(4,1,3,3) = 1
Lb(4,2,3,3) = 1
Lb(4,3,3,3) = 1
Lb(4,3,4,3) = 1
Lb(4,1,4,4) = 1
Lb(4,2,4,4) = 1
Lb(4,2,3,4) = 1
Lb(4,2,2,4) = 1
;;___________________________________________
Lb(5,1,4,1) = 1 ;; __,----
Lb(5,2,4,1) = 1
Lb(5,2,3,1) = 1
Lb(5,3,3,1) = 1
Lb(5,1,2,2) = 1
Lb(5,1,3,2) = 1
Lb(5,2,3,2) = 1
Lb(5,2,4,2) = 1
Lb(5,1,4,3) = 1
Lb(5,2,4,3) = 1
Lb(5,2,3,3) = 1
Lb(5,3,3,3) = 1
Lb(5,1,2,4) = 1
Lb(5,1,3,4) = 1
Lb(5,2,3,4) = 1
Lb(5,2,4,4) = 1
;;___________________________________________
Lb(6,1,3,1) = 1 ;; ----,__
Lb(6,2,3,1) = 1
Lb(6,2,4,1) = 1
Lb(6,3,4,1) = 1
Lb(6,2,2,2) = 1
Lb(6,2,3,2) = 1
Lb(6,1,3,2) = 1
Lb(6,1,4,2) = 1
Lb(6,1,3,3) = 1
Lb(6,2,3,3) = 1
Lb(6,2,4,3) = 1
Lb(6,3,4,3) = 1
Lb(6,2,2,4) = 1
Lb(6,2,3,4) = 1
Lb(6,1,3,4) = 1
Lb(6,1,4,4) = 1
;;___________________________________________
Lb(7,1,4,1) = 1 ;; . : .
Lb(7,2,4,1) = 1
Lb(7,2,3,1) = 1
Lb(7,3,4,1) = 1
Lb(7,1,2,2) = 1
Lb(7,1,3,2) = 1
Lb(7,2,3,2) = 1
Lb(7,1,4,2) = 1
Lb(7,1,3,3) = 1
Lb(7,2,3,3) = 1
Lb(7,2,4,3) = 1
Lb(7,3,3,3) = 1
Lb(7,2,2,4) = 1
Lb(7,1,3,4) = 1
Lb(7,2,3,4) = 1
Lb(7,2,4,4) = 1
EndProcedure
Procedure init_logic()
;;___________________________________________
Lb(1,1,3,1) = 1 ;; : : Clockwise rotation
Lb(1,2,3,1) = 1
Lb(1,1,4,1) = 1
Lb(1,2,4,1) = 1
Lb(1,1,3,2) = 1
Lb(1,2,3,2) = 1
Lb(1,1,4,2) = 1
Lb(1,2,4,2) = 1
Lb(1,1,3,3) = 1
Lb(1,2,3,3) = 1
Lb(1,1,4,3) = 1
Lb(1,2,4,3) = 1
Lb(1,1,3,4) = 1
Lb(1,2,3,4) = 1
Lb(1,1,4,4) = 1
Lb(1,2,4,4) = 1
;;___________________________________________
Lb(2,1,1,1) = 1
Lb(2,1,2,1) = 1
Lb(2,1,3,1) = 1
Lb(2,1,4,1) = 1
Lb(2,1,4,2) = 1 ;; - - - -
Lb(2,2,4,2) = 1
Lb(2,3,4,2) = 1
Lb(2,4,4,2) = 1
Lb(2,1,1,3) = 1
Lb(2,1,2,3) = 1
Lb(2,1,3,3) = 1
Lb(2,1,4,3) = 1
Lb(2,1,4,4) = 1
Lb(2,2,4,4) = 1
Lb(2,3,4,4) = 1
Lb(2,4,4,4) = 1
;;___________________________________________
Lb(3,1,4,1) = 1 ;; ___|
Lb(3,2,4,1) = 1
Lb(3,3,4,1) = 1
Lb(3,3,3,1) = 1
Lb(3,2,4,2) = 1
Lb(3,1,4,2) = 1
Lb(3,1,3,2) = 1
Lb(3,1,2,2) = 1
Lb(3,1,4,3) = 1
Lb(3,1,3,3) = 1
Lb(3,2,3,3) = 1
Lb(3,3,3,3) = 1
Lb(3,1,2,4) = 1
Lb(3,2,2,4) = 1
Lb(3,2,3,4) = 1
Lb(3,2,4,4) = 1
;;___________________________________________
Lb(4,1,3,1) = 1 ;; |___
Lb(4,1,4,1) = 1
Lb(4,2,4,1) = 1
Lb(4,3,4,1) = 1
Lb(4,2,2,2) = 1
Lb(4,1,2,2) = 1
Lb(4,1,3,2) = 1
Lb(4,1,4,2) = 1
Lb(4,1,3,3) = 1
Lb(4,2,3,3) = 1
Lb(4,3,3,3) = 1
Lb(4,3,4,3) = 1
Lb(4,1,4,4) = 1
Lb(4,2,4,4) = 1
Lb(4,2,3,4) = 1
Lb(4,2,2,4) = 1
;;___________________________________________
Lb(5,1,2,1) = 1
Lb(5,1,3,1) = 1
Lb(5,2,3,1) = 1
Lb(5,2,4,1) = 1
Lb(5,1,4,2) = 1 ;; __,----
Lb(5,2,4,2) = 1
Lb(5,2,3,2) = 1
Lb(5,3,3,2) = 1
Lb(5,1,2,3) = 1
Lb(5,1,3,3) = 1
Lb(5,2,3,3) = 1
Lb(5,2,4,3) = 1
Lb(5,1,4,4) = 1
Lb(5,2,4,4) = 1
Lb(5,2,3,4) = 1
Lb(5,3,3,4) = 1
;;___________________________________________
Lb(6,2,2,1) = 1
Lb(6,2,3,1) = 1
Lb(6,1,3,1) = 1
Lb(6,1,4,1) = 1
Lb(6,1,3,2) = 1 ;; ----,__
Lb(6,2,3,2) = 1
Lb(6,2,4,2) = 1
Lb(6,3,4,2) = 1
Lb(6,2,2,3) = 1
Lb(6,2,3,3) = 1
Lb(6,1,3,3) = 1
Lb(6,1,4,3) = 1
Lb(6,1,3,4) = 1
Lb(6,2,3,4) = 1
Lb(6,2,4,4) = 1
Lb(6,3,4,4) = 1
;;___________________________________________
Lb(7,1,4,1) = 1 ;; . : .
Lb(7,2,4,1) = 1
Lb(7,2,3,1) = 1
Lb(7,3,4,1) = 1
Lb(7,1,2,2) = 1
Lb(7,1,3,2) = 1
Lb(7,2,3,2) = 1
Lb(7,1,4,2) = 1
Lb(7,1,3,3) = 1
Lb(7,2,3,3) = 1
Lb(7,2,4,3) = 1
Lb(7,3,3,3) = 1
Lb(7,2,2,4) = 1
Lb(7,1,3,4) = 1
Lb(7,2,3,4) = 1
Lb(7,2,4,4) = 1
EndProcedure
Procedure init_draw()
If OpenWindow(0, 0, 0, 425, 502, " Fourski III", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If CreateGadgetList(WindowID(0))
ButtonGadget(0, 310, 435, 85, 22, "Mom's home!!!")
TextGadget(1, 300, 40, 110, 18, "Hello", #PB_Text_Center)
TextGadget(2, 300, 58, 110, 20, "Hello", #PB_Text_Center|#PB_Text_Border)
TextGadget(3, 300, 120, 110, 20, "Hello", #PB_Text_Center|#PB_Text_Border)
TextGadget(4, 300, 142, 110, 20, "Hello", #PB_Text_Center|#PB_Text_Border)
TextGadget(5, 300, 300, 110, 18, "/\ Rotate \/", #PB_Text_Center)
TextGadget(6, 300, 330, 110, 18, "< Left<>Right >", #PB_Text_Center)
TextGadget(7, 300, 360, 110, 18, "Enter-Drop", #PB_Text_Center)
TextGadget(8, 300, 390, 110, 18, "Space-Pause", #PB_Text_Center)
TextGadget(9, 300, 170, 110, 18, "Player Mode", #PB_Text_Center|#PB_Text_Border)
ButtonGadget(10, 310, 255, 85, 22, "Silent Mode")
EndIf
GameBoard.l = OpenWindowedScreen(WindowID(0), 0, 0, 280, 502, 0, 0, 0)
If GameBoard.l
ClearScreen(RGB(0, 0, 0))
; If StartDrawing(WindowOutput(0))
; Box(99, 29, 262, 421, RGB(255, 0, 0)) ; blank row
; StopDrawing()
; EndIf
CreateSprite(0, 20, 20)
If StartDrawing(SpriteOutput(0))
Box(0, 0, 19, 19, RGB(110, 110, 110)) ; blank row
StopDrawing()
EndIf
;-
;/Color 1
; : :
ClearScreen(RGB(0, 0, 0))
CreateSprite(1, 40, 80)
If StartDrawing(SpriteOutput(1))
Box(0, 40, 19, 19, RGB(195, 0, 155))
Box(0, 60, 19, 19, RGB(195, 0, 155))
Box(20, 40, 19, 19, RGB(195, 0, 155))
Box(20, 60, 19, 19, RGB(195, 0, 155))
StopDrawing()
EndIf
CopySprite(1,2)
CopySprite(1,3)
CopySprite(1,4)
;/Color 2
; - - - -
ClearScreen(RGB(0, 0, 0))
CreateSprite(5, 40, 80)
If StartDrawing(SpriteOutput(5))
Box(0, 0, 19, 19, RGB(0, 100, 155))
Box(0, 20, 19, 19, RGB(0, 100, 155))
Box(0, 40, 19, 19, RGB(0, 100, 155))
Box(0, 60, 19, 19, RGB(0, 100, 155))
StopDrawing()
EndIf
ClearScreen(RGB(0, 0, 0))
CreateSprite(6, 80, 80)
If StartDrawing(SpriteOutput(6))
Box(0, 60, 19, 19, RGB(0, 100, 155))
Box(20, 60, 19, 19, RGB(0, 100, 155))
Box(40, 60, 19, 19, RGB(0, 100, 155))
Box(60, 60, 19, 19, RGB(0, 100, 155))
StopDrawing()
EndIf
CopySprite(5,7)
CopySprite(6,8)
;/Color 3
; ___|
ClearScreen(RGB(0, 0, 0))
CreateSprite(9, 60, 80)
If StartDrawing(SpriteOutput(9))
Box(0, 60, 19, 19, RGB(155, 100, 0))
Box(20, 60, 19, 19, RGB(155, 100, 0))
Box(40, 60, 19, 19, RGB(155, 100, 0))
Box(40, 40, 19, 19, RGB(155, 100, 0))
StopDrawing()
EndIf
ClearScreen(RGB(0, 0, 0))
CreateSprite(10, 60, 80)
If StartDrawing(SpriteOutput(10))
Box(0, 20, 19, 19, RGB(155, 100, 0))
Box(0, 40, 19, 19, RGB(155, 100, 0))
Box(0, 60, 19, 19, RGB(155, 100, 0))
Box(20, 60, 19, 19, RGB(155, 100, 0))
StopDrawing()
EndIf
ClearScreen(RGB(0, 0, 0))
CreateSprite(11, 60, 80)
If StartDrawing(SpriteOutput(11))
Box(0, 40, 19, 19, RGB(155, 100, 0))
Box(20, 40, 19, 19, RGB(155, 100, 0))
Box(40, 40, 19, 19, RGB(155, 100, 0))
Box(0, 60, 19, 19, RGB(155, 100, 0))
StopDrawing()
EndIf
ClearScreen(RGB(0, 0, 0))
CreateSprite(12, 40, 80)
If StartDrawing(SpriteOutput(12))
Box(0, 20, 19, 19, RGB(155, 100, 0))
Box(20, 20, 19, 19, RGB(155, 100, 0))
Box(20, 40, 19, 19, RGB(155, 100, 0))
Box(20, 60, 19, 19, RGB(155, 100, 0))
StopDrawing()
EndIf
;/Color 4
; |___
ClearScreen(RGB(0, 0, 0))
CreateSprite(13, 60, 80)
If StartDrawing(SpriteOutput(13))
Box(0, 40, 19, 19, RGB(0, 200, 55))
Box(0, 60, 19, 19, RGB(0, 200, 55))
Box(20, 60, 19, 19, RGB(0, 200, 55))
Box(40, 60, 19, 19, RGB(0, 200, 55))
StopDrawing()
EndIf
ClearScreen(RGB(0, 0, 0))
CreateSprite(14, 40, 80)
If StartDrawing(SpriteOutput(14))
Box(0, 20, 19, 19, RGB(0, 200, 55))
Box(0, 40, 19, 19, RGB(0, 200, 55))
Box(0, 60, 19, 19, RGB(0, 200, 55))
Box(20, 20, 19, 19, RGB(0, 200, 55))
StopDrawing()
EndIf
ClearScreen(RGB(0, 0, 0))
CreateSprite(15, 60, 80)
If StartDrawing(SpriteOutput(15))
Box(0, 40, 19, 19, RGB(0, 200, 55))
Box(20, 40, 19, 19, RGB(0, 200, 55))
Box(40, 40, 19, 19, RGB(0, 200, 55))
Box(40, 60, 19, 19, RGB(0, 200, 55))
StopDrawing()
EndIf
ClearScreen(RGB(0, 0, 0))
CreateSprite(16, 40, 80)
If StartDrawing(SpriteOutput(16))
Box(0, 60, 19, 19, RGB(0, 200, 55))
Box(20, 20, 19, 19, RGB(0, 200, 55))
Box(20, 40, 19, 19, RGB(0, 200, 55))
Box(20, 60, 19, 19, RGB(0, 200, 55))
StopDrawing()
EndIf
;/Color 5
;; __,----
ClearScreen(RGB(0, 0, 0))
CreateSprite(17, 40, 80)
If StartDrawing(SpriteOutput(17))
Box(0, 20, 19, 19, RGB(255, 100, 0))
Box(0, 40, 19, 19, RGB(255, 100, 0))
Box(20, 40, 19, 19, RGB(255, 100, 0))
Box(20, 60, 19, 19, RGB(255, 100, 0))
StopDrawing()
EndIf
CreateSprite(18, 60, 80)
If StartDrawing(SpriteOutput(18))
Box(0, 60, 19, 19, RGB(255, 100, 0))
Box(20, 60, 19, 19, RGB(255, 100, 0))
Box(20, 40, 19, 19, RGB(255, 100, 0))
Box(40, 40, 19, 19, RGB(255, 100, 0))
StopDrawing()
EndIf
CopySprite(17,19)
CopySprite(18,20)
;/Color 6
; ----,__
ClearScreen(RGB(0, 0, 0))
CreateSprite(21, 40, 80)
If StartDrawing(SpriteOutput(21))
Box(20, 20, 19, 19, RGB(245, 215, 55))
Box(20, 40, 19, 19, RGB(245, 215, 55))
Box(0, 40, 19, 19, RGB(245, 215, 55))
Box(0, 60, 19, 19, RGB(245, 215, 55))
StopDrawing()
EndIf
CreateSprite(22, 60, 80)
If StartDrawing(SpriteOutput(22))
Box(0, 40, 19, 19, RGB(245, 215, 55))
Box(20, 40, 19, 19, RGB(245, 215, 55))
Box(20, 60, 19, 19, RGB(245, 215, 55))
Box(40, 60, 19, 19, RGB(245, 215, 55))
StopDrawing()
EndIf
CopySprite(21,23)
CopySprite(22,24)
;/Color 7
; . : .
ClearScreen(RGB(0, 0, 0))
CreateSprite(25, 60, 80)
If StartDrawing(SpriteOutput(25))
Box(0, 60, 19, 19, RGB(255, 90, 145))
Box(20, 40, 19, 19, RGB(255, 90, 145))
Box(20, 60, 19, 19, RGB(255, 90, 145))
Box(40, 60, 19, 19, RGB(255, 90, 145))
StopDrawing()
EndIf
ClearScreen(RGB(0, 0, 0))
CreateSprite(26, 40, 80)
If StartDrawing(SpriteOutput(26))
Box(0, 20, 19, 19, RGB(255, 90, 145))
Box(0, 40, 19, 19, RGB(255, 90, 145))
Box(0, 60, 19, 19, RGB(255, 90, 145))
Box(20, 40, 19, 19, RGB(255, 90, 145))
StopDrawing()
EndIf
ClearScreen(RGB(0, 0, 0))
CreateSprite(27, 60, 80)
If StartDrawing(SpriteOutput(27))
Box(0, 40, 19, 19, RGB(255, 90, 145))
Box(20, 40, 19, 19, RGB(255, 90, 145))
Box(40, 40, 19, 19, RGB(255, 90, 145))
Box(20, 60, 19, 19, RGB(255, 90, 145))
StopDrawing()
EndIf
ClearScreen(RGB(0, 0, 0))
CreateSprite(28, 40, 80)
If StartDrawing(SpriteOutput(28))
Box(0, 40, 19, 19, RGB(255, 90, 145))
Box(20, 20, 19, 19, RGB(255, 90, 145))
Box(20, 40, 19, 19, RGB(255, 90, 145))
Box(20, 60, 19, 19, RGB(255, 90, 145))
StopDrawing()
EndIf
;-
;/Color 1
; : :
ClearScreen(RGB(0, 0, 0))
CreateSprite(29, 40, 80)
If StartDrawing(SpriteOutput(29))
Box(0, 40, 19, 19, RGB(1, 0, 0))
Box(20, 40, 19, 19, RGB(1, 0, 0))
Box(0, 60, 19, 19, RGB(1, 0, 0))
Box(20, 60, 19, 19, RGB(1, 0, 0))
StopDrawing()
EndIf
CopySprite(29,30)
CopySprite(29,31)
CopySprite(29,32)
;/Color 2
; - - - -
ClearScreen(RGB(0, 0, 0))
CreateSprite(33, 40, 80)
If StartDrawing(SpriteOutput(33))
Box(0, 0, 19, 19, RGB(1, 0, 0))
Box(0, 20, 19, 19, RGB(1, 0, 0))
Box(0, 40, 19, 19, RGB(1, 0, 0))
Box(0, 60, 19, 19, RGB(1, 0, 0))
StopDrawing()
EndIf
ClearScreen(RGB(0, 0, 0))
CreateSprite(34, 80, 80)
If StartDrawing(SpriteOutput(34))
Box(0, 60, 19, 19, RGB(1, 0, 0))
Box(20, 60, 19, 19, RGB(1, 0, 0))
Box(40, 60, 19, 19, RGB(1, 0, 0))
Box(60, 60, 19, 19, RGB(1, 0, 0))
StopDrawing()
EndIf
CopySprite(33,35)
CopySprite(34,36)
;/Color 3
; ___|
ClearScreen(RGB(0, 0, 0))
CreateSprite(37, 60, 80)
If StartDrawing(SpriteOutput(37))
Box(0, 60, 19, 19, RGB(1, 0, 0))
Box(20, 60, 19, 19, RGB(1, 0, 0))
Box(40, 60, 19, 19, RGB(1, 0, 0))
Box(40, 40, 19, 19, RGB(1, 0, 0))
StopDrawing()
EndIf
ClearScreen(RGB(0, 0, 0))
CreateSprite(38, 60, 80)
If StartDrawing(SpriteOutput(38))
Box(0, 20, 19, 19, RGB(1, 0, 0))
Box(0, 40, 19, 19, RGB(1, 0, 0))
Box(0, 60, 19, 19, RGB(1, 0, 0))
Box(20, 60, 19, 19, RGB(1, 0, 0))
StopDrawing()
EndIf
ClearScreen(RGB(0, 0, 0))
CreateSprite(39, 60, 80)
If StartDrawing(SpriteOutput(39))
Box(0, 40, 19, 19, RGB(1, 0, 0))
Box(20, 40, 19, 19, RGB(1, 0, 0))
Box(40, 40, 19, 19, RGB(1, 0, 0))
Box(0, 60, 19, 19, RGB(1, 0, 0))
StopDrawing()
EndIf
ClearScreen(RGB(0, 0, 0))
CreateSprite(40, 40, 80)
If StartDrawing(SpriteOutput(40))
Box(0, 20, 19, 19, RGB(1, 0, 0))
Box(20, 20, 19, 19, RGB(1, 0, 0))
Box(20, 40, 19, 19, RGB(1, 0, 0))
Box(20, 60, 19, 19, RGB(1, 0, 0))
StopDrawing()
EndIf
;/Color 4
; |___
ClearScreen(RGB(0, 0, 0))
CreateSprite(41, 60, 80)
If StartDrawing(SpriteOutput(41))
Box(0, 40, 19, 19, RGB(1, 0, 0))
Box(0, 60, 19, 19, RGB(1, 0, 0))
Box(20, 60, 19, 19, RGB(1, 0, 0))
Box(40, 60, 19, 19, RGB(1, 0, 0))
StopDrawing()
EndIf
ClearScreen(RGB(0, 0, 0))
CreateSprite(42, 40, 80)
If StartDrawing(SpriteOutput(42))
Box(0, 20, 19, 19, RGB(1, 0, 0))
Box(0, 40, 19, 19, RGB(1, 0, 0))
Box(0, 60, 19, 19, RGB(1, 0, 0))
Box(20, 20, 19, 19, RGB(1, 0, 0))
StopDrawing()
EndIf
ClearScreen(RGB(0, 0, 0))
CreateSprite(43, 60, 80)
If StartDrawing(SpriteOutput(43))
Box(0, 40, 19, 19, RGB(1, 0, 0))
Box(20, 40, 19, 19, RGB(1, 0, 0))
Box(40, 40, 19, 19, RGB(1, 0, 0))
Box(40, 60, 19, 19, RGB(1, 0, 0))
StopDrawing()
EndIf
ClearScreen(RGB(0, 0, 0))
CreateSprite(44, 40, 80)
If StartDrawing(SpriteOutput(44))
Box(0, 60, 19, 19, RGB(1, 0, 0))
Box(20, 20, 19, 19, RGB(1, 0, 0))
Box(20, 40, 19, 19, RGB(1, 0, 0))
Box(20, 60, 19, 19, RGB(1, 0, 0))
StopDrawing()
EndIf
;/Color 5
;; __,----
ClearScreen(RGB(0, 0, 0))
CreateSprite(45, 40, 80)
If StartDrawing(SpriteOutput(45))
Box(0, 20, 19, 19, RGB(1, 0, 0))
Box(0, 40, 19, 19, RGB(1, 0, 0))
Box(20, 40, 19, 19, RGB(1, 0, 0))
Box(20, 60, 19, 19, RGB(1, 0, 0))
StopDrawing()
EndIf
ClearScreen(RGB(0, 0, 0))
CreateSprite(46, 60, 80)
If StartDrawing(SpriteOutput(46))
Box(0, 60, 19, 19, RGB(1, 0, 0))
Box(20, 60, 19, 19, RGB(1, 0, 0))
Box(20, 40, 19, 19, RGB(1, 0, 0))
Box(40, 40, 19, 19, RGB(1, 0, 0))
StopDrawing()
EndIf
CopySprite(45,47)
CopySprite(46,48)
;/Color 6
; ----,__
ClearScreen(RGB(0, 0, 0))
CreateSprite(49, 40, 80)
If StartDrawing(SpriteOutput(49))
Box(20, 20, 19, 19, RGB(1, 0, 0))
Box(20, 40, 19, 19, RGB(1, 0, 0))
Box(0, 40, 19, 19, RGB(1, 0, 0))
Box(0, 60, 19, 19, RGB(1, 0, 0))
StopDrawing()
EndIf
ClearScreen(RGB(0, 0, 0))
CreateSprite(50, 60, 80)
If StartDrawing(SpriteOutput(50))
Box(0, 40, 19, 19, RGB(1, 0, 0))
Box(20, 40, 19, 19, RGB(1, 0, 0))
Box(20, 60, 19, 19, RGB(1, 0, 0))
Box(40, 60, 19, 19, RGB(1, 0, 0))
StopDrawing()
EndIf
CopySprite(49,51)
CopySprite(50,52)
;/Color 7
; . : .
ClearScreen(RGB(0, 0, 0))
CreateSprite(53, 60, 80)
If StartDrawing(SpriteOutput(53))
Box(0, 60, 19, 19, RGB(1, 0, 0))
Box(20, 40, 19, 19, RGB(1, 0, 0))
Box(20, 60, 19, 19, RGB(1, 0, 0))
Box(40, 60, 19, 19, RGB(1, 0, 0))
StopDrawing()
EndIf
ClearScreen(RGB(0, 0, 0))
CreateSprite(54, 40, 80)
If StartDrawing(SpriteOutput(54))
Box(0, 20, 19, 19, RGB(1, 0, 0))
Box(0, 40, 19, 19, RGB(1, 0, 0))
Box(0, 60, 19, 19, RGB(1, 0, 0))
Box(20, 40, 19, 19, RGB(1, 0, 0))
StopDrawing()
EndIf
ClearScreen(RGB(0, 0, 0))
CreateSprite(55, 60, 80)
If StartDrawing(SpriteOutput(55))
Box(0, 40, 19, 19, RGB(1, 0, 0))
Box(20, 40, 19, 19, RGB(1, 0, 0))
Box(40, 40, 19, 19, RGB(1, 0, 0))
Box(20, 60, 19, 19, RGB(1, 0, 0))
StopDrawing()
EndIf
ClearScreen(RGB(0, 0, 0))
CreateSprite(56, 40, 80)
If StartDrawing(SpriteOutput(56))
Box(0, 40, 19, 19, RGB(1, 0, 0))
Box(20, 20, 19, 19, RGB(1, 0, 0))
Box(20, 40, 19, 19, RGB(1, 0, 0))
Box(20, 60, 19, 19, RGB(1, 0, 0))
StopDrawing()
EndIf
;/
ClearScreen(RGB(0, 0, 0))
CreateSprite(57, 159, 440)
If StartDrawing(SpriteOutput(57))
Box(0, 0, 159, 440, RGB(1, 0, 0))
StopDrawing()
EndIf
SetGadgetText(1, "Your score is:")
Else
MessageRequester("Error", "Can't open windowed screen!", 0)
End
EndIf
EndIf
EndProcedure
Procedure setup()
For x = 0 To 20
For y = 0 To 43
l(x,y) = 0 ; Clear L() Array
Next
Next
bR.l = 1
bL.l = 1
bH.l = 1
x = 101
y.l = 11
score=0
speed=1500
; Print At(15,22);"Press: Esc to quit, N to start new game, Space to pause"
; Print At(22,24);"Use arrows for left/right/rotate, Enter to drop"
ClearScreen(RGB(0, 0, 0))
; 0, 0, 262, 443, RGB(255, 0, 0)
For r.l = 0 To 9
A$ = Right(Str(ElapsedMilliseconds()),2)
n.w = Val(A$) + Random(144)
n.w = n.w % 7
r.l(r.l) = n.w + 1
l(r.l,23) = 1
(0, 99 + 16 * r, 29, 255) ;Draw New Sprite
DisplayTranslucentSprite(0, 99 + 16 * r, 453, 255) ;Draw New Sprite
; FlipBuffers()
Next r.l
For bH.l = 0 To 43
DisplayTranslucentSprite(0, 99, 9.8*bH+29, 255) ;Draw New Sprite
DisplayTranslucentSprite(0, 243, 9.8*bH+29, 255) ;Draw New Sprite
l(0, bH.l) = 1
l(9, bH.l) = 1
Next bH.l
DisplayTranslucentSprite(57, 101, 31, 255) ;Draw New Sprite
Shape.l = (bN.l-1)*4
Shape.l = (r.l(9))*4 -3
DisplayTranslucentSprite(Shape, 10, 200, 255) ;Draw New Sprite
FlipBuffers()
Delay(10)
WaitWindowEvent(20)
Repeat
Event = WindowEvent()
Until Event=0
answer.l = MessageRequester(" Choose difficulty "," Are you still a beginner?",#PB_MessageRequester_YesNo)
If answer = #PB_MessageRequester_No
SetGadgetText(9,"I'm An Expert")
Else
beginner = #True
SetGadgetText(9,"Learning Mode")
EndIf
SetGadgetText(3, "Beat your score!")
grabNext4()
;;;
;SetGadgetText(1, Str(shape))
;;;
EndProcedure
Procedure randomizeRarray()
A$ = Right(Str(ElapsedMilliseconds()),2)
n.w = Val(A$) + Random(160)
n.w = n.w % 7
R.l(9) = R.l(8)
R.l(8) = R.l(7)
R.l(7) = R.l(6)
R.l(6) = R.l(5)
R.l(5) = R.l(4)
R.l(4) = R.l(3)
R.l(3) = R.l(2)
R.l(2) = R.l(1)
R.l(1) = R.l(0)
R.l(0) = n.w + 1
EndProcedure
Procedure grabNext4()
bN.l = R.l(9)
bR.l = 1
bL.l = 1
bH.l = 1
x = 101
y.l = 31
t.l = 0
For x1 = 1 To 4
For y1.l = 1 To 4
If (Lb(bN.l,x1,y1.l,bR.l) & L(bL.l - 1 + x1,bH.l - 1 + y1.l)) = 1
t.l = 1
EndIf
Next y1.l
Next x1
If t.l
SetGadgetText(2, Str(score))
SetGadgetText(3, "GAME OVER")
Delay(2000)
; Print At(48,0);
result = MessageRequester(" That was fun!","Start a new game?",#PB_MessageRequester_YesNo)
scoreB4 = score
If result = #PB_MessageRequester_Yes
setup()
SetGadgetText(4, Str(scoreB4))
Else
End
EndIf
Else
;;;
shape.l = (R.l(9))*4 -3
DisplayTranslucentSprite(shape+28, 10, 200, 255) ;Draw New Sprite
; FlipBuffers()
;;;
shape.l = (R.l(8))*4 -3
DisplayTranslucentSprite(shape, 10, 200, 255) ;Coming New Sprite
; FlipBuffers()
;;;
shape.l = (R.l(9))*4 -3
DisplayTranslucentSprite(shape, x, y, 255) ;Draw New Sprite
FlipBuffers()
;;;
randomizeRarray()
If beginner.l = #True
speed = speed*0.998
Else
speed = speed*0.988
EndIf
wait=ElapsedMilliseconds()+speed
SetGadgetText(2, Str(score))
Select score
Case 1000 To 4999
SetGadgetText(3, "Great start!")
Case 5000 To 7999
SetGadgetText(3, "Savy player!")
Case 8000 To 9999
SetGadgetText(3, "All warmed up!")
Case 10000 To 11999
SetGadgetText(3, "Cranking it!")
Case 12000 To 200000
SetGadgetText(3, "Digi brain!!")
EndSelect
EndIf
;t.l=1
EndProcedure
Procedure shiftLeft()
t.l = 0
For x1 = 1 To 4
For y1.l = 1 To 4
If (Lb(bN.l,x1,y1.l,bR.l) & L(bL.l - 2 + x1,bH.l - 1 + y1.l)) = 1
t.l = 1
EndIf
Next y1.l
Next x1
If t.l = 0
;;;
shape.l = (bN.l-1)*4 + bR.l
DisplayTranslucentSprite(shape+28, x, y, 255) ;Clear current sprite
bL.l - 1
x - 20
DisplayTranslucentSprite(shape, x, y, 255) ;Draw New Sprite
FlipBuffers()
;;;
EndIf
EndProcedure
Procedure rotate()
t.l = 0
bX.l = bR.l + 1
If bX.l = 5
bX.l = 1
EndIf
For x1 = 1 To 4
For y1.l = 1 To 4
If (Lb(bN.l,x1,y1.l,bX.l) & L(bL.l - 1 + x1,bH.l - 1 + y1.l)) = 1
t.l = 1
EndIf
Next y1.l
Next x1
If t.l = 0
;;;
shape.l = (R.l(9))*4 -3
shape.l = (bN.l-1)*4 + bR.l
DisplayTranslucentSprite(shape+28, x, y, 255) ;Clear current sprite
bR.l = bX.l
shape.l = (bN.l-1)*4 + bR.l
DisplayTranslucentSprite(shape, x, y, 255) ;Draw New Sprite
FlipBuffers()
;;;
EndIf
EndProcedure
Procedure shiftRight()
t.l = 0
For x1 = 1 To 4
For y1.l = 1 To 4
If (Lb(bN.l,x1,y1.l,bR.l) & L(bL.l + x1,bH.l - 1 + y1.l)) = 1
t.l = 1
EndIf
Next y1.l
Next x1
If t.l = 0
;;;
shape.l = (bN.l-1)*4 + bR.l
DisplayTranslucentSprite(shape+28, x, y, 255) ;Clear current sprite
bL.l + 1
x + 20
DisplayTranslucentSprite(shape, x, y, 255) ;Draw New Sprite
FlipBuffers()
;;;
EndIf
EndProcedure
Procedure flash()
For bJ.l=4 To 1 Step -1
If t.l(bJ.l)
score + 10
For bX = 1 To 4
GrabSprite(58,101,411,160,20)
For c.l=1 To 4
FlipBuffers()
DisplayTranslucentSprite(0, 81+c*20, (bH.l+3)*20+11 , 255) ;Draw New Sprite
DisplayTranslucentSprite(0, 101+(8-c)*20, (bH.l+3)*20+11 , 255) ;Draw New Sprite
FlipBuffers()
Delay(5)
Next c.l
DisplayTranslucentSprite(58, 101, (bH.l+3)*20+11 , 255) ;Draw New Sprite
FlipBuffers()
FreeSprite(58)
Next bX
If sfx And scard
PlaySound(4)
EndIf
Delay(25)
For c.l = bH + 3 To 3 Step -1
For x1=1 To 8
L(x1,c)=L(x1,c-1)
L(x1,c-1)=0
Next x1
Next c.l
GrabSprite(58, 101, 31, 160, (bH.l+3)*20-21)
DisplayTranslucentSprite(58, 101, 51, 255) ;Draw New Sprite
FlipBuffers()
FreeSprite(58)
Else
bH.l - 1
EndIf
Next bJ.l
EndProcedure
Procedure checkRow()
T.l(0) = 0
T.l(1) = 0
T.l(2) = 0
T.l(3) = 0
T.l(4) = 0
For y1.l = 1 To 4
If l(1,bH.l - 1 + y1.l) & l(2,bH.l - 1 + y1.l) = 1
If l(3,bH.l - 1 + y1.l) & l(4,bH.l - 1 + y1.l) = 1
If l(5,bH.l - 1 + y1.l) & l(6,bH.l - 1 + y1.l) = 1
If l(7,bH.l - 1 + y1.l) & l(8,bH.l - 1 + y1.l) = 1
T.l(y1.l) = 1 ;; track Rows that are full
EndIf
EndIf
EndIf
EndIf
Next
flash()
EndProcedure
Procedure drop()
T.l = 0
settled.l = 0
For x1 = 1 To 4
For y1.l = 1 To 4
If (Lb(bN.l,x1, y1.l,bR.l) & l(bL.l - 1 + x1, bH.l + y1.l)) = 1
T.l = 1 ;; Flag it unable To drop.
EndIf
Next y1.l
Next x1
If T.l ;; unable To drop
For x1 = 1 To 4
For y1.l = 1 To 4
If Lb(bN.l, x1, y1.l, bR.l) & 1
l(bL.l - 1 + x1, bH.l - 1 + y1.l) = 1
settled.l = 1
EndIf
Next y1.l
Next x1
;;;
checkRow()
grabNext4()
FlipBuffers()
Else ;; Able To drop
;;;
If settled.l = 0
score + 1
Shape.l = (bN.l-1)*4 + bR.l
DisplayTranslucentSprite(Shape+28, x, y, 255) ;Clear current sprite
; FlipBuffers()
bH.l + 1
y + 20
DisplayTranslucentSprite(Shape, x, y, 255) ;Draw New Sprite
FlipBuffers()
If sfx And scard
PlaySound(0)
EndIf
SetGadgetText(2, Str(score))
EndIf
;;;
EndIf
EndProcedure
Procedure userInputLoop()
T.l = 0
wait=ElapsedMilliseconds()+speed
Repeat
key = 0
Repeat
Event = WindowEvent() : _wParam=EventwParam() : _lParam=EventlParam()
Select Event
Case #WM_KEYDOWN ;- KEYBOARD ACTION
Select _wParam
Case #VK_LEFT ;/ < GO Left<<<<
shiftLeft()
If sfx And scard
PlaySound(1)
EndIf
Case #VK_UP, #VK_DOWN ;/ /\Rotate\/
rotate()
If sfx And scard
PlaySound(1)
EndIf
Case #VK_RIGHT ;/ >>>>GO Right >
shiftRight()
If sfx And scard
PlaySound(1)
EndIf
Case #VK_RETURN ; \ || /
score + 10
Repeat ;/ Drop
drop(); \/
Until settled.l = 1
settled.l = 0
Case #VK_ESCAPE ;/ Escape to Quit
; Print At(48,0);
;Input "Quit Game Now? y/N ";A$
result = MessageRequester(" That was fun!","Time to quit already?",#PB_MessageRequester_YesNo)
If result = #PB_MessageRequester_Yes
End
EndIf
wait=ElapsedMilliseconds()+speed
;
Case #VK_SPACE ;/ Pause To Pee
If sfx And scard
PlaySound(5)
EndIf
result = MessageRequester(" Pee break! ^_^","Spacebar to continue...",#PB_MessageRequester_Ok)
wait=ElapsedMilliseconds()+speed
If sfx And scard
PlaySound(6)
EndIf
EndSelect
Case #PB_Event_Gadget ;- BUTTON ACTION
Select EventGadget()
Case 0
End
Case 10
If sfx
sfx = #False
SetGadgetText(10,"Silent Mode")
Else
sfx = #True
SetGadgetText(10,"Sound On")
EndIf
EndSelect
Case #PB_Event_CloseWindow
End
EndSelect
Until Event = 0
Tick=ElapsedMilliseconds()
If Tick >wait
wait + speed
drop()
FlipBuffers()
EndIf
Delay(1)
ForEver
EndProcedure
;-PROGRAM STARTS HERE
pretest()
init_draw()
init_logic()
setup()
userInputLoop()
End