Author Topic: Dual Crew Shining (DCS) remake + PureBasic source code  (Read 5762 times)

0 Members and 1 Guest are viewing this topic.

Offline padman

  • Senior Member
  • Pentium
  • ********
  • Posts: 990
  • Karma: 260
    • View Profile
Well, well, it was about time, wasn't it?  ^^

Here's a new Amiga remake + source. Why? Because I can.  :P
I always liked the bouncing coco arts logo in this one and when I saw it on flashtro.com, I decided to convert it to Purebasic. The Romeo Knight tune has a glitch in the beginning, when being played back with sc68, so I also added a SWF version created with FLOD for fun, which plays the tune fine.  Hence two files, dcs_sc68.pb and dcs_swf.pb, in the ZIP archive.

Anyways, below is the listing of the sc68 version. Everything else, including exe's can be found in the attached ZIP. Feel free to do whatever you want with the code. If you spot any crap, feel free to correct it. I know it's not perfect, should have used a 800x600 screen for example and it's always better to replay SWFs in a thread... But hey, it's free! ;)

Pad  :cheers:

Code: [Select]
;******************************************************************************************
;* DCS remake converted from / based on an HTML5 source by musashi9 with a couple of      *
;* modifications. Well, it's actually a different version of the cracktro... ^^           *
;* Original Source: http://www.flashtro.com/index.php?e=page&c=AmigaHTML5&id=4127         *
;* SC68 originally created by Stormbringer                                                *
;* Hacked together, heavily commented & compiled with PureBasic 5.40 LTS x86              *
;* by Padman in 2016.                                                                     *                                                   
;******************************************************************************************




XIncludeFile "sc68/sc68.pbi"


InitSprite() : InitKeyboard()



OpenScreen(640,480,32,"DCS Remake")



CatchSprite(1,?cocoarts)
ZoomSprite(1,SpriteWidth(1)*2,SpriteHeight(1)*2)

CatchSprite(2,?heart)
ZoomSprite(2,SpriteWidth(2)*2,SpriteHeight(2)*2)

CatchImage(3,?font)

CreateSprite(4,320,256)

  StartDrawing(SpriteOutput(4))
    Box(0,0,320,256,$FF00FF)
  StopDrawing()

  TransparentSpriteColor(4,$FF00FF)

sinus.f=0
ccnt=0
bounce=#False
rnd.f=0
credx=100*2
xs=1       
textlength=?textend-?text-1 
tmp.f=0
tmp1.f=0
tmp2.f=0
tmp3.f=0
texty=0
px.f=0
py.f=0
Global newx=0
Global exx=0

Global Dim csin(18)   : Global Dim sizetab(126) : Global Dim postab(126) : Global Dim text(1638)             


Procedure calcStartX(num)

For ii=0 To 59

  val=text(num+ii) ;
exx=exx+sizetab(val);
If val=1
newx=320-exx
newx=newx/2
Break
EndIf
Next ii

exx=0
EndProcedure



Restore credit

For i =0 To 17
  Read csin(i)
Next i 


Restore sizetab

For i= 0 To 125
  Read sizetab(i)
Next i


Restore postab

For i= 0 To 125
  Read postab(i)
Next i



For i= 0 To 1637
   text(i)=PeekB(?text+i) 
Next i




sc68replay_Init(?song , ?songend-?song, #SC68Replay_Memory)   ; Init tune
sc68replay_Play() ; Start tune

calcstartx(0)

timer=(ElapsedMilliseconds()/30)

Repeat
 
  ClearScreen($FFFFFF)
 
 
  fade+5 :If fade>255 : fade=255 : EndIf
 
 
 
 ;///////////////////////////////// Bouncing CoCo Arts Logo /////////////////
 
 
  sinus=Round(Sin(tmp*#PI/180)*22,#PB_Round_Down)
  tmp=tmp+3.2
 

  If sinus=>0
    sinus=sinus*-1
    EndIf
   
    If sinus=0 Or sinus=1 Or sinus=-1
      bounce=#True
      rnd=1+Round(Random(2)*3,#PB_Round_Down)
      If rnd=1
        xs=-2
      Else
        xs=2
       EndIf
     EndIf
     
     DisplaySprite(2,80,32+sinus)
     DisplaySprite(1,credx,400+csin(ccnt))
       
       If bounce=#True
         ccnt=ccnt+1
         credx=credx+xs
       EndIf
       
        If credx>520 
           xs=xs*-2
           credx=credx-2
         EndIf
         
         If credx<=0
           xs=xs*-2
           credx=credx+2
         EndIf
         
         If ccnt=>17
           ccnt=0
           bounce=#False
        EndIf
         
       
       
       
        ;////////////////// PAGE TEXT  ////////////////////
           

  wait=(ElapsedMilliseconds()/30)-timer
 
  If wait>=0
val=text(txtcnt);
;calc char pos
tmp1=Round(postab(val),#PB_Round_Down)
tmp2=(tmp1/264);
tmp1=Round(tmp2,#PB_Round_Down);
tmp3=Round((tmp2*264)-(tmp1*264),#PB_Round_Nearest);



size=sizetab(val)

If size<>1
 
StartDrawing(SpriteOutput(4)) 
 
   GrabImage(3,4,tmp3*8,tmp1*11,size,11)
   DrawImage(ImageID(4),Round(newx+px,#PB_Round_Down),Round(py,#PB_Round_Down));

  StopDrawing()
 EndIf
; add a char with its custom width
px=px+sizetab(val);
txtcnt=txtcnt+1;

; start a new text page
If val=2 And txtcnt<textlength
  timer=(ElapsedMilliseconds()/30)+260
px=0;
py=0;

calcStartX(txtcnt);
EndIf

;new text line
If val=1
px=0;
py=py+12;
calcStartX(txtcnt);
EndIf

Debug wait

;reset all text vars
If txtcnt>=textlength
  timer=(ElapsedMilliseconds()/30)+260
px=0;
py=0;
    txtcnt=0;
calcStartX(txtcnt);
EndIf

Else
 
 
 
  ;move textsprite off screen
If wait>=-79
txty-8;
EndIf

;clear text screen by drawing a box on the textsprite
If wait =-1
  StartDrawing(SpriteOutput(4)) 
        Box(0,0,320,256,$FF00FF)
     StopDrawing()
  txty=0;
EndIf
EndIf


;zoom textsprite and bounce it
ZoomSprite(4,320*2,256*2)
DisplayTransparentSprite(4,0,txty+12-sinus,fade)



  ExamineKeyboard()
 
  FlipBuffers()
 
Until KeyboardPushed(#PB_Key_Escape)


sc68replay_Stop()
 


End


DataSection
  cocoarts:
  IncludeBinary  "inc/cred.bmp"
  heart:
  IncludeBinary  "inc/heart.bmp"
  font:
  IncludeBinary  "inc/font.bmp"
  credit:
  Data.l $34,$26,$1A,$10,$8,$4,$4,$6,$0C,$14,$1E,$2C,$36,$2E,$2A,$2A,$2C,$32
  sizetab:
  Data.l 1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,4,5,7,7,0,0,4,5,5,7,5,4,5,4,0,7,5,6,6,7,6,7,6,7,7,3,0,0,5,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,8,8,7,7,7,7,7,6,7,7,5,7,7,4,5,7,4,7,7,7,7,7,5,6,5,7,7,7,7,7,7,6,5,6,15;
  postab:
  Data.l 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,269,528,538,280,281,0,0,537,533,534,536,535,531,532,530,0,270,271,272,273,274,275,276,277,278,279,282,0,0,539,0,529,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,540,541,542,266,267,268,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,264,265,543,544,545;
  text:
  IncludeBinary "inc/text.bin"
  textend:
  song:
  IncludeBinary "inc/enigma-gun.sc68"             
  songend: 
EndDataSection


Challenge Trophies Won:

Offline spitfire

  • Amiga 1200
  • ****
  • Posts: 275
  • Karma: 9
    • View Profile
Cute :) Which part does the coco bounce? Is that data driven cuz I dont see any trigonometry?

Offline padman

  • Senior Member
  • Pentium
  • ********
  • Posts: 990
  • Karma: 260
    • View Profile
Yup, it's data driven. The data is stored in the csin array:

Code: [Select]
 
Global Dim csin(18)

(...)

Restore credit

For i =0 To 17
  Read csin(i)
Next i 

(...)
Datasection

credit:  Data.l $34,$26,$1A,$10,$8,$4,$4,$6,$0C,$14,$1E,$2C,$36,$2E,$2A,$2A,$2C,$32

The stuff around

Code: [Select]
DisplaySprite(1,credx,400+csin(ccnt))
is responsible for displaying the logo on screen.

Challenge Trophies Won:

Offline Kirl

  • Senior Member
  • Pentium
  • ********
  • Posts: 1217
  • Karma: 230
    • View Profile
    • Homepage
Wonderful, I do so love that tune!  :clap:
www.kirl.nl
Challenge Trophies Won:

Offline ~Ar-S~

  • C= 64
  • **
  • Posts: 61
  • Karma: 26
  • Demo RuleZ
    • View Profile
Fun :)
Thanks for sharing. Nice swf trick  :cheers:
~ Ar-S ~

Offline aNdy

  • C= 64
  • **
  • Posts: 93
  • Karma: 30
    • View Profile
Some nice learning material here. Thanks for share.