Dark Bit Factory & Gravity

PROGRAMMING => Purebasic => Topic started by: padman on November 30, 2010

Title: Anthrox cracktro remake + PureBasic source code
Post by: padman on November 30, 2010
Hey @ll!

I once started to convert this for RR and had it almost finished when I realised, that it was already on RR. Duh!!! I know...  ::)
(The FC replay in my version sounds better imho though and the crunched binary is smaller!  :kewl:)
Anyway, before deleting it I decided to make a quick'n'dirty "special" version out of it and release it here with the source included. Maybe someone finds it useful, though it's only a small piece of code.

It's been developed with PB 4.41, but should work with any PB version 4.x. Make sure to put the included FC replay userlib in the "\PureLibraries\UserLibraries" folder and restart the IDE before trying to compile the source!

Enjoy!

Pad

Edit: [Space] switches between windowed and fullscreen, if you are only about to test the executable  ;)

Code: [Select]
;############################################################# #
;# Quick and crap ATX cracktro remake by Padman. (c)11/2010    #
;# Uses a purebasic userlib by eNeRGy/dAWN for FC playback,    #
;# which itself is based on a library by SiRioKD\Lockless.     #
;###############################################################

         
Procedure StaticText(spritenr,x,y,width,height,txt$)
  For n=1 To Len(txt$)
   a = Asc(Mid(txt$,n,1))-32
   ClipSprite(spritenr, a * width, 0, width, height)
   DisplayTransparentSprite(spritenr, x + width * (n-1), y)
Next
EndProcedure

Procedure.l KeyboardHit( KeyName.l )
  Static Dim KeyFlag.b(255)
  If KeyboardPushed(KeyName)
    If KeyFlag(KeyName) = 0
      KeyFlag(KeyName) = 1
      ProcedureReturn 1
    Else
      ProcedureReturn 0
    EndIf
  Else
    KeyFlag(KeyName) = 0
    ProcedureReturn 0
  EndIf
EndProcedure

IncludeFile  "text.pbi"       ; the file containing the text strings

InitSprite()     
InitKeyboard()   

      window=OpenWindow(0, 0, 0, 720, 568, "ATX Remake", #PB_Window_BorderLess | #PB_Window_ScreenCentered )
      OpenWindowedScreen(WindowID(0), 0, 0, 720, 568, #True, 0, 0)   ; the #True flag sets the screen to autostretch


 
         If window = 0                                       
             MessageRequester("Error", "Can't open windowed screen!", 0)    ; at least some error handling   
             End                                                   
         EndIf
         
         
         CatchSprite(0,?font)          ; load our font
         CatchSprite(1,?logo)          ; load our logo

         dAWN_TinyFC4Play(?song,1)      ; load and start playing the FC module, "1" means it's played from memory
                                        ; "0" will play from a file:
                                        ;
                                        ; song.s="delta fc"               
                                        ; dAWN_TinyFC4Play(@song,0)
       
       
        Repeat

           ClearScreen(0)
 
               If WaitWindowEvent(1) = #PB_Key_Escape :  End :EndIf
       
   
         ;let's draw the background stuff 
               
               StartDrawing(ScreenOutput())                     
               Box(0,35,720,2,$FFFFFF)                ;Upper line
               Box(0,37,720,356,$553333)              ;Text background
               Box(0,393,720,2,$FFFFFF)               ;Lower line
               StopDrawing()
       
       
       ; and now the text lines... Empty one's aren't really needed, you can comment them
       ;(... yeah I know there's probably better ways to do this :P)
         StaticText(0,((720-Len(s00)*8)/2),77,8,16,s00)
         StaticText(0,((720-Len(s01)*8)/2),91,8,16,s01)
         StaticText(0,((720-Len(s02)*8)/2),105,8,16,s02)
         StaticText(0,((720-Len(s03)*8)/2),119,8,16,s03)
         StaticText(0,((720-Len(s04)*8)/2),133,8,16,s04)
         StaticText(0,((720-Len(s05)*8)/2),147,8,16,s05)
         StaticText(0,((720-Len(s06)*8)/2),161,8,16,s06)
         StaticText(0,((720-Len(s07)*8)/2),175,8,16,s07)
         StaticText(0,((720-Len(s08)*8)/2),191,8,16,s08)
         StaticText(0,((720-Len(s09)*8)/2),207,8,16,s09)
         StaticText(0,((720-Len(s10)*8)/2),225,8,16,s10)
         StaticText(0,((720-Len(s11)*8)/2),244,8,16,s11)
         StaticText(0,((720-Len(s12)*8)/2),267,8,16,s12)
         StaticText(0,((720-Len(s13)*8)/2),283,8,16,s13)
         StaticText(0,((720-Len(s14)*8)/2),297,8,16,s14)
         StaticText(0,((720-Len(s15)*8)/2),311,8,16,s15)
         StaticText(0,((720-Len(s16)*8)/2),328,8,16,s16)
         
         DisplaySprite(1,((720-SpriteWidth(1))/2),404)       ; last but not least display the logo
 
 ExamineKeyboard()   ; check if some buttons have been pressed



 If KeyboardHit(#PB_Key_Space)      ; if it's [SPACE] then we'll switch between windowed and fullscreen
     If Status=0 : Status = 1 :Else : Status = 0 : EndIf
 EndIf

; very crappy windowed / fake fullscreen switch, too lazy for a proper fullscreen version ;)
         Select Status
               Case 0
                  ShowWindow_(WindowID(0),#SW_NORMAL)      ;WinAPI calls won't work in the Demo of PureBasic!
               Case 1
                  ShowWindow_(WindowID(0),#SW_MAXIMIZE)
         EndSelect

FlipBuffers()    ; flip da screen

Until KeyboardPushed(#PB_Key_Escape)  ;until someone gets bored and presses [ESC]


dAWN_TinyFC4Free()     ; unload the FC module

End                   ;buhbye


DataSection
logo: IncludeBinary "logo.bmp"
font: IncludeBinary "font.bmp"
song:IncludeBinary  "delta.fc"
EndDataSection

Title: Re: Anthrox cracktro remake + PureBasic source code
Post by: Hotshot on November 30, 2010
it`s good and run well :)
Title: Re: Anthrox cracktro remake + PureBasic source code
Post by: energy on December 01, 2010
For me too, well done!

Nice to see Purebasic Remakes.
Title: Re: Anthrox cracktro remake + PureBasic source code
Post by: benny! on December 01, 2010
N1
Title: Re: Anthrox cracktro remake + PureBasic source code
Post by: padman on December 01, 2010
Thanks guys!  :)
Title: Re: Anthrox cracktro remake + PureBasic source code
Post by: Maxx on February 26, 2011
Nice Work  :clap:
Title: Re: Anthrox cracktro remake + PureBasic source code
Post by: AmigaFreak on May 28, 2012
@ padman: Good work!!!11eleven  :D

I have include now some music in your code, but my question:

How can I include two, three,... more textpages and/or a 1-line textscroller between logo and textpage?

well known from http://retro-remakes.net/viewproduction.php?prod=58a107559c4c173d2eb01d5880d3d151b69e4af6

Thanks  ;)
Title: Re: Anthrox cracktro remake + PureBasic source code
Post by: jace_stknights on May 28, 2012
How can I include two, three,... more textpages and/or a 1-line textscroller between logo and textpage?

You have to include counter and a pointer to the text. The counter is equal to, for example 2*60 frames for 2 seconds of display (You can use ElapsedTime for exact time count)

This text should be in a single var (and not in one for each lines, like in this example), with a special char of the end and a special on for the end of page if you want not fill all caracters
Each frame, you decrease the counter and when it is at zero, you change the pointer to a new page, and so on...
For the scrolltext, just have to rip the one from the fucktro example, and remove the circle coords ;)
Title: Re: Anthrox cracktro remake + PureBasic source code
Post by: jace_stknights on May 29, 2012
Here is a quick example:
Code: [Select]
;############################################################# #
;# Quick and crap ATX cracktro remake by Padman. (c)11/2010    #
;# Uses a purebasic userlib by eNeRGy/dAWN for FC playback,    #
;# which itself is based on a library by SiRioKD\Lockless.     #
;###############################################################

Procedure.l KeyboardHit( KeyName.l )
  Static Dim KeyFlag.b(255)
  If KeyboardPushed(KeyName)
    If KeyFlag(KeyName) = 0
      KeyFlag(KeyName) = 1
      ProcedureReturn 1
    Else
      ProcedureReturn 0
    EndIf
  Else
    KeyFlag(KeyName) = 0
    ProcedureReturn 0
  EndIf
EndProcedure

;###############mod by Jace/St Knights #############################

#size=57 ; size of the line
ptext = 0 ; index of the text for each page
pausetext = 2*60 ; 2 * 60 frames for 2 seconds

text.s="        ____  __  __________________  _______  ___       "
text + " +------\   \|  \|  __  __/|  _____ \/    \  \/  /-----+ "
text + " :::::::/_/| \      |/  |  _  | _|/ /  /\_ \_   /::::::: "
text + " ::::::/ \__  \ \  _/   |  |  | \_  \  \_/  /   \::::::: "
text + " :::::\  _||__/ |\_\____|__|  |__|\  \_____/ /\__/:::::: "                   
text + " +-----\/----|__|----------|__|----\__/--\__/----------+ "
text + "                                                         "
text + "                  * FOR FUN, NOT STATUS *                "
text + "                                                         "
text + "                                                         "
text + "     ------------------------------------------------    "
text + "     Bully's Sporting Darts From Alternative Software    "
text + "     ------------------------------------------------    "
text + "                                                         "
text + "                                                         "
text + "                                                         "
text + "Original Music By ROB HUBBARD, Amiga Rendition By WALKMAN"

text + "                                                         "
text + "       Page 2                                            "
text + "                                                         "
text + "                                                         "
text + "                                                         "
text + "                                                         "
text + "       bla bla                                           "
text + "                                                         "
text + "                                                         "
text + "                                                         "
text + "                                                         "
text + "                                                         "
text + "                                                         "
text + "                                                         "
text + "                                                         "
text + "                                                         "
text + "                                                         "

text + "                                                         "
text + "       Page 3                                            "
text + "                                                         "
text + "                                                         "
text + "                                                         "
text + "                                                         "
text + "       bla bla                                           "
text + "                                                         "
text + "                                                         "
text + "                                                         "
text + "                                                         "
text + "                                                         "
text + "           and looooop!                                  "
text + "                                                         "
text + "                                                         "
text + "                                                         "
text + "                                                         "

Procedure StaticText(spritenr,x,y,width,height,txt$)
  For n=1 To Len(txt$)
   a = Asc(Mid(txt$,n,1))-32
   ClipSprite(spritenr, a * width, 0, width, height)
   DisplayTransparentSprite(spritenr, x + width * (n-1), y)
  Next
EndProcedure

Procedure DisplayText(pt,t.s)
  Protected x = ((720-#size*8)/2)
  Protected y = 77
 
  For i=0 To 17-1
    StaticText(0,x,y,8,16,Mid(t,(pt+1)+i*#size,#size))    ;beware : mid() starts at 1 :D
    y + 14
  Next i
 
EndProcedure

;###################################################################

InitSprite()     
InitKeyboard()   

      window=OpenWindow(0, 0, 0, 720, 568, "ATX Remake", #PB_Window_BorderLess | #PB_Window_ScreenCentered )
      OpenWindowedScreen(WindowID(0), 0, 0, 720, 568, #True, 0, 0)   ; the #True flag sets the screen to autostretch


 
         If window = 0                                       
             MessageRequester("Error", "Can't open windowed screen!", 0)    ; at least some error handling   
             End                                                   
         EndIf
         
         
         CatchSprite(0,?font)          ; load our font
         CatchSprite(1,?logo)          ; load our logo

         dAWN_TinyFC4Play(?song,1)      ; load and start playing the FC module, "1" means it's played from memory
                                        ; "0" will play from a file:
                                        ;
                                        ; song.s="delta fc"               
                                        ; dAWN_TinyFC4Play(@song,0)
       
       
        Repeat

           ClearScreen(0)
 
               If WaitWindowEvent(1) = #PB_Key_Escape :  End :EndIf
       
   
         ;let's draw the background stuff 
               
               StartDrawing(ScreenOutput())                     
               Box(0,35,720,2,$FFFFFF)                ;Upper line
               Box(0,37,720,356,$553333)              ;Text background
               Box(0,393,720,2,$FFFFFF)               ;Lower line
               StopDrawing()
               
               
               
;###############mod by Jace/St Knights #############################

          DisplayText(ptext,text) ; display the text

          pausetext - 1
          If pausetext = 0
            pausetext = 2*60 ;60 frames in each seconds (you can use elapsed time for millisecond count)
           
            ptext + #size*17  ; add a page
            If ptext >= Len(text)
              ptext = 0       ;restart
            EndIf
           
          EndIf
         
;##################################################################
         
         DisplaySprite(1,((720-SpriteWidth(1))/2),404)       ; last but not least display the logo
 
 ExamineKeyboard()   ; check if some buttons have been pressed



 If KeyboardHit(#PB_Key_Space)      ; if it's [SPACE] then we'll switch between windowed and fullscreen
     If Status=0 : Status = 1 :Else : Status = 0 : EndIf
 EndIf

; very crappy windowed / fake fullscreen switch, too lazy for a proper fullscreen version ;)
         Select Status
               Case 0
                  ShowWindow_(WindowID(0),#SW_NORMAL)      ;WinAPI calls won't work in the Demo of PureBasic!
               Case 1
                  ShowWindow_(WindowID(0),#SW_MAXIMIZE)
         EndSelect

FlipBuffers()    ; flip da screen

Until KeyboardPushed(#PB_Key_Escape)  ;until someone gets bored and presses [ESC]


dAWN_TinyFC4Free()     ; unload the FC module

End                   ;buhbye


DataSection
logo: IncludeBinary "logo.bmp"
font: IncludeBinary "font.bmp"
song:IncludeBinary  "delta.fc"
EndDataSection