Code Breaker Game
Code Breaker Game
I'm looking for some examples for a hobby project of mine.
I want to display a fullscreen window with a countdown timer (the value of which the user can set in a preference file). What is the best way to show a somewhat animated countdown timer on a 2D window? Get images for all of the numbers and rotate them out? Use the text drawing functions?
I also want to display a text box and ask the user to type in a code. Basically the goal of the whole thing will be to get the right code entered before the timer gets to zero. Sounds goofy, I know, but it is a small part of a bigger project.
I'm pretty clueless when it comes to anything graphically with PB so any hints and tips are appreciated.
I want to display a fullscreen window with a countdown timer (the value of which the user can set in a preference file). What is the best way to show a somewhat animated countdown timer on a 2D window? Get images for all of the numbers and rotate them out? Use the text drawing functions?
I also want to display a text box and ask the user to type in a code. Basically the goal of the whole thing will be to get the right code entered before the timer gets to zero. Sounds goofy, I know, but it is a small part of a bigger project.
I'm pretty clueless when it comes to anything graphically with PB so any hints and tips are appreciated.
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
I'll leave the digit animation part out as I'm learning myself... But to make things pretty, texture maker could help. You can make a animated fire and place it on the screen when countdown is reaching zero... Something like it's burning dude... Move it!
See http://www.texturemaker.com.
Anyway, here's my simple example of solid and dithered font using Data and Sprites... Maybe it can lead to something...
See http://www.texturemaker.com.
Anyway, here's my simple example of solid and dithered font using Data and Sprites... Maybe it can lead to something...
Code: Select all
InitSprite()
#DATA_FONT_WIDTH = 10
#DATA_FONT_HEIGHT = 16
#DATA_FONT_COLOR1 = 16777200 ; RGB(255, 255, 255)
#DATA_FONT_COLOR2 = 8355711 ; RGB(127, 127, 127)
#DATA_FONT_BACKGROUND = 127 ; RGB(127, 0, 0)
Macro LoadFontSprite(num)
fs_#num# = CreateSprite(#PB_Any, #DATA_FONT_WIDTH, #DATA_FONT_HEIGHT)
If fs_#num#
If StartDrawing(SpriteOutput(fs_#num#))
Box(0, 0, #DATA_FONT_WIDTH, #DATA_FONT_HEIGHT, #DATA_FONT_BACKGROUND)
StopDrawing()
EndIf
; Use dithered font
Restore dit_#num#
; Use solid font
; Restore chr_#num#
For fs_y = 0 To #DATA_FONT_HEIGHT - 1
For fs_x = 0 To #DATA_FONT_WIDTH - 1
Read fs_pix.b
If fs_pix
If StartDrawing(SpriteOutput(fs_#num#))
If fs_pix = 1
Plot(fs_x, fs_y, #DATA_FONT_COLOR1)
Else
Plot(fs_x, fs_y, #DATA_FONT_COLOR2)
EndIf
StopDrawing()
EndIf
EndIf
Next
Next
Else
Debug "fs_" + Str(num)
EndIf
EndMacro
winhandle = OpenWindow(#PB_Any, #PB_Any, #PB_Any, 800, 600, "DirectX Window", #PB_Window_SystemMenu | #PB_Window_WindowCentered)
OpenWindowedScreen(WindowID(winhandle), 10, 10, 640, 480, 0, 0, 0)
LoadFontSprite(0)
LoadFontSprite(1)
LoadFontSprite(2)
LoadFontSprite(3)
LoadFontSprite(4)
LoadFontSprite(5)
LoadFontSprite(6)
LoadFontSprite(7)
LoadFontSprite(8)
LoadFontSprite(9)
running = #True
While running
FlipBuffers()
ClearScreen(RGB(0, 0, 0))
DisplaySprite(fs_0, 10, 10)
DisplaySprite(fs_1, 20, 10)
DisplaySprite(fs_2, 30, 10)
DisplaySprite(fs_3, 40, 10)
DisplaySprite(fs_4, 50, 10)
DisplaySprite(fs_5, 60, 10)
DisplaySprite(fs_6, 70, 10)
DisplaySprite(fs_7, 80, 10)
DisplaySprite(fs_8, 90, 10)
DisplaySprite(fs_9, 100, 10)
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
running = #False
EndSelect
Wend
; Solid 10 x 16
DataSection
chr_0:
Data.b 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Data.b 0, 1, 1, 1, 1, 1, 1, 1, 1, 0
Data.b 0, 1, 1, 1, 1, 1, 1, 1, 1, 0
Data.b 0, 1, 1, 0, 0, 0, 0, 1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b 0, 1, 1, 1, 1, 1, 1, 1, 1, 0
Data.b 0, 2, 1, 1, 1, 1, 1, 1, 2, 0
Data.b 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
dit_9:
Data.b 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Data.b 0, 2, 1, 1, 1, 1, 1, 1, 2, 0
Data.b 0, 1, 1, 1, 1, 1, 1, 1, 1, 0
Data.b 0, 1, 1, 0, 0, 0, 0, 1, 1, 0
Data.b 0, 1, 1, 0, 0, 0, 0, 1, 1, 0
Data.b 0, 1, 1, 0, 0, 0, 0, 1, 1, 0
Data.b 0, 1, 1, 0, 0, 0, 0, 1, 1, 0
Data.b 0, 1, 1, 1, 1, 1, 1, 1, 1, 0
Data.b 0, 2, 1, 1, 1, 1, 1, 1, 1, 0
Data.b 0, 0, 0, 0, 0, 0, 0, 1, 1, 0
Data.b 0, 0, 0, 0, 0, 0, 0, 1, 1, 0
Data.b 0, 0, 0, 0, 0, 0, 0, 1, 1, 0
Data.b 0, 0, 0, 0, 0, 0, 0, 1, 1, 0
Data.b 0, 1, 1, 1, 1, 1, 1, 1, 1, 0
Data.b 0, 1, 1, 1, 1, 1, 1, 1, 2, 0
Data.b 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
EndDataSection
- Rook Zimbabwe
- Addict

- Posts: 4322
- Joined: Tue Jan 02, 2007 8:16 pm
- Location: Cypress TX
- Contact:
Nice!
I have one question:
I edited the chr1 a bit because it was too far shoved into the 2... it looks like I didn't change it a bit!
Even with this code:
Why?
I have one question:
I edited the chr1 a bit because it was too far shoved into the 2... it looks like I didn't change it a bit!
Code: Select all
chr_1:
Data.b 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Data.b 0, 0, 0, 1, 1, 0, 0, 0, 0, 0
Data.b 0, 0, 0, 1, 1, 0, 0, 0, 0, 0
Data.b 0, 0, 0, 1, 1, 0, 0, 0, 0, 0
Data.b 0, 0, 0, 1, 1, 0, 0, 0, 0, 0
Data.b 0, 0, 0, 1, 1, 0, 0, 0, 0, 0
Data.b 0, 0, 0, 1, 1, 0, 0, 0, 0, 0
Data.b 0, 0, 0, 1, 1, 0, 0, 0, 0, 0
Data.b 0, 0, 0, 1, 1, 0, 0, 0, 0, 0
Data.b 0, 0, 0, 1, 1, 0, 0, 0, 0, 0
Data.b 0, 0, 0, 1, 1, 0, 0, 0, 0, 0
Data.b 0, 0, 0, 1, 1, 0, 0, 0, 0, 0
Data.b 0, 0, 0, 1, 1, 0, 0, 0, 0, 0
Data.b 0, 0, 0, 1, 1, 0, 0, 0, 0, 0
Data.b 0, 0, 0, 1, 1, 0, 0, 0, 0, 0
Data.b 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Code: Select all
chr_1:
Data.b 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Data.b 0, 1, 1, 0, 0, 0, 0, 0, 0, 0
Data.b 0, 1, 1, 0, 0, 0, 0, 0, 0, 0
Data.b 0, 1, 1, 0, 0, 0, 0, 0, 0, 0
Data.b 0, 1, 1, 0, 0, 0, 0, 0, 0, 0
Data.b 0, 1, 1, 0, 0, 0, 0, 0, 0, 0
Data.b 0, 1, 1, 0, 0, 0, 0, 0, 0, 0
Data.b 0, 1, 1, 0, 0, 0, 0, 0, 0, 0
Data.b 0, 1, 1, 0, 0, 0, 0, 0, 0, 0
Data.b 0, 1, 1, 0, 0, 0, 0, 0, 0, 0
Data.b 0, 1, 1, 0, 0, 0, 0, 0, 0, 0
Data.b 0, 1, 1, 0, 0, 0, 0, 0, 0, 0
Data.b 0, 1, 1, 0, 0, 0, 0, 0, 0, 0
Data.b 0, 1, 1, 0, 0, 0, 0, 0, 0, 0
Data.b 0, 1, 1, 0, 0, 0, 0, 0, 0, 0
Data.b 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Oh ok... Change the macro LoadFontSprite() to...
if you are using chr then it is for the solid font...
the example use the dithered array...
Code: Select all
; Use dithered font
; Restore dit_#num#
; Use solid font
Restore chr_#num#the example use the dithered array...
- Rook Zimbabwe
- Addict

- Posts: 4322
- Joined: Tue Jan 02, 2007 8:16 pm
- Location: Cypress TX
- Contact:
Thats IT!!!
The following looks best with your fix...
I wonder how this could be translated into BINARY... I mean having a number that would be parsed into BIN form that would create the character. I mean my 1 here = 0,48,48,48... etc.
Hmmm... With this system you could code a whole ATARI style retro game.
I haven't done much in the games arena... poked my toe in the water a couple of times since B3D, but this gives me ideas!
OK as far as the input box... draw a box.
As far as trapping input... You simply have to:
1. create an alphabet the same way as the numbers are created (you can code an editor in about 45 minutes I bet that would output TXT files for cut and paste!) [OK you really don't... but it would be COOL!
2. Addkeyboard shortcuts to the screenwindow
3. when A-Z is pressed position TXT in input box you drew. (Centered might be best...
You can also create a spritebutton and check for mouseup collision for enter OR look for the enter key as well and bind your check routine to it!
The following looks best with your fix...
Code: Select all
chr_1:
Data.b 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Data.b 0, 0, 0, 0, 1, 1, 0, 0, 0, 0
Data.b 0, 0, 0, 0, 1, 1, 0, 0, 0, 0
Data.b 0, 0, 0, 0, 1, 1, 0, 0, 0, 0
Data.b 0, 0, 0, 0, 1, 1, 0, 0, 0, 0
Data.b 0, 0, 0, 0, 1, 1, 0, 0, 0, 0
Data.b 0, 0, 0, 0, 1, 1, 0, 0, 0, 0
Data.b 0, 0, 0, 0, 1, 1, 0, 0, 0, 0
Data.b 0, 0, 0, 0, 1, 1, 0, 0, 0, 0
Data.b 0, 0, 0, 0, 1, 1, 0, 0, 0, 0
Data.b 0, 0, 0, 0, 1, 1, 0, 0, 0, 0
Data.b 0, 0, 0, 0, 1, 1, 0, 0, 0, 0
Data.b 0, 0, 0, 0, 1, 1, 0, 0, 0, 0
Data.b 0, 0, 0, 0, 1, 1, 0, 0, 0, 0
Data.b 0, 0, 0, 0, 1, 1, 0, 0, 0, 0
Data.b 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Hmmm... With this system you could code a whole ATARI style retro game.
I haven't done much in the games arena... poked my toe in the water a couple of times since B3D, but this gives me ideas!
OK as far as the input box... draw a box.
As far as trapping input... You simply have to:
1. create an alphabet the same way as the numbers are created (you can code an editor in about 45 minutes I bet that would output TXT files for cut and paste!) [OK you really don't... but it would be COOL!
2. Addkeyboard shortcuts to the screenwindow
3. when A-Z is pressed position TXT in input box you drew. (Centered might be best...
You can also create a spritebutton and check for mouseup collision for enter OR look for the enter key as well and bind your check routine to it!
- Rook Zimbabwe
- Addict

- Posts: 4322
- Joined: Tue Jan 02, 2007 8:16 pm
- Location: Cypress TX
- Contact:
I snarked together a quick CHR editor.
You are gonna need 3 pictures (2 JPG (but you can change that)) and 1 BMP with RGB(0,0,0) as Transparent color for the cursor
All images 32X32
This code, with a little modification can also become a MAP EDITOR...
Gotta go now and prepare for the HURRICANE!
You will need to add the routine to dump the array CHAR() to out put the code you clicked up!
Good luck!
You are gonna need 3 pictures (2 JPG (but you can change that)) and 1 BMP with RGB(0,0,0) as Transparent color for the cursor
All images 32X32
This code, with a little modification can also become a MAP EDITOR...
Code: Select all
; MAP / TILE Editor Base Code by
;Rook Zimbabwe - Ralph
; added insight and much code sorted by
; DemiVec - Jared
;
Enumeration
#Window_0
EndEnumeration
Enumeration
#ZERO
#WUN
#MOUSE
#Button_FILE
#Frame3D_1
#Image_1
#Frame3D_0
EndEnumeration
#LeftOffset = 32
#TopOffset = 32
Structure VisualDesignerGadgets
Gadget.l
EventFunction.l
EndStructure
Global NewList EventProcedures.VisualDesignerGadgets()
Global Dim CHAR(9,12)
UseJPEGImageDecoder()
Global Image1
DataSection
Image0:
IncludeBinary "black1.jpg"
Image1:
IncludeBinary "Cursor1.bmp"
Image2:
IncludeBinary "white1.jpg"
EndDataSection
InitSprite()
InitMouse()
InitKeyboard()
Procedure NewCHR()
For X = 0 To 9
For y = 0 To 12
char(X,Y) = #ZERO
Next
Next
EndProcedure
Procedure ShowCHR()
For X = 0 To 9
For Y = 0 To 12
; was gonna amke a TXT Array view on the side
Next
Next
EndProcedure
Procedure DoScreenDisplay(inscreen)
;
; Display your screen stuff
If inscreen ; manage mouse events only if mouse is inside screen
ClearScreen(0)
WindowEvent()
ExamineMouse()
MausX$ = Str(MouseX())
MausY$ = Str(MouseY())
EndIf
EndProcedure
;-
Procedure Button_FILE_Event(Window, Event, Gadget, Type)
Debug "#Button_FILE"
EndProcedure
;-
Procedure RegisterGadgetEvent(Gadget, *Function)
If IsGadget(Gadget)
AddElement(EventProcedures())
EventProcedures()\Gadget = Gadget
EventProcedures()\EventFunction = *Function
EndIf
EndProcedure
Procedure CallEventFunction(Window, Event, Gadget, Type)
ForEach EventProcedures()
If EventProcedures()\Gadget = Gadget
CallFunctionFast(EventProcedures()\EventFunction, Window, Event, Gadget, Type)
LastElement(EventProcedures())
EndIf
Next
EndProcedure
;-
Procedure Open_Window_0()
If OpenWindow(#Window_0, 5, 5, 516, 542, "CHRmaker 0", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
If CreateGadgetList(WindowID(#Window_0))
Frame3DGadget(#Frame3D_0, 405, 20, 90, 90, "VIEW")
Frame3DGadget(#Frame3D_1, 10, 20, 360, 445, "EDIT")
ButtonGadget(#Button_FILE, 390, 125, 105, 40, "OUTPUT")
RegisterGadgetEvent(#Button_FILE, @Button_FILE_Event())
EndIf
EndIf
EndProcedure
Open_Window_0()
OpenWindowedScreen(WindowID(#Window_0),25,35,335,425,0,0,0)
CatchSprite(#ZERO, ?Image0)
CatchSprite(#Mouse, ?Image1,#PB_Sprite_Memory)
CatchSprite(#WUN, ?Image2,0)
NewCHR()
; use debug to view array at startup
For y = 0 To 12
For x = 0 To 9
choke$ = choke$ + Str(CHAR(x,y))
Next
Debug "R "+Str(y) + ": "+choke$
choke$ = ""
Next
Repeat
Event = WaitWindowEvent(8)
If inscreen
If MouseX()>332 Or MouseY()>422 Or MouseX()<1 Or MouseY()<1
ReleaseMouse(1)
inscreen = #False
EndIf
Else
Gadget = EventGadget()
Type = EventType()
Window = EventWindow()
Select Event
Case #PB_Event_Gadget
CallEventFunction(Window, Event, Gadget, Type)
EndSelect
mx = WindowMouseX(0):my = WindowMouseY(0)
If mx < 300+#LeftOffset And mx > #LeftOffset And my > #TopOffset And my < #TopOffset+390
ReleaseMouse(0)
MouseLocate(mx-#LeftOffset,my-#TopOffset)
inscreen = #True
EndIf
EndIf
DoScreenDisplay(inscreen)
If MouseButton(#PB_MouseButton_Left)
; set new tile number into array
ax = (MouseX() + 1) / 32 ;these show coordinates of tile in map
ay = (MouseY() + 1) / 32
CHAR(ax,ay) = #WUN
EndIf
If MouseButton(#PB_MouseButton_Right)
; set new tile number into array
ax = (MouseX() + 1) / 32 ;these show coordinates of tile in map
ay = (MouseY() + 1) / 32
CHAR(ax,ay) = #ZERO
EndIf
YYY = 0
For y = 0 To 12
XXX = 0
For x = 0 To 9
DisplaySprite(CHAR(x,y),XXX , YYY) ; (LAYER(x,y),XXX , YYY) ; nothing shows up either way!
XXX + 32
Next
YYY + 32
Next
DisplayTransparentSprite(#Mouse,MouseX(),MouseY())
FlipBuffers(4)
Until Event = #PB_Event_CloseWindow
End
You will need to add the routine to dump the array CHAR() to out put the code you clicked up!
Good luck!
Really nice.
And I didn't know you could do this in Purebasic:
and change the variable name dynamically while compiling. 
And I didn't know you could do this in Purebasic:
Code: Select all
fs_#num#Proud registered Purebasic user.
Because programming should be fun.
Because programming should be fun.
- Rook Zimbabwe
- Addict

- Posts: 4322
- Joined: Tue Jan 02, 2007 8:16 pm
- Location: Cypress TX
- Contact:


