https://www.youtube.com/watch?v=grr7xluRmp0&t=1s
* Backstory alert! Skip if not interested! *
I played the demo of this nice game A LOT as a kid, the game was way ahead of it's time too!
Drove my dad crazy when i wanted to buy the game, he explained to me the game was to old and the "buy now" form was not valid anymore...
After looking for the full version for many many years i gave up for a while, i looked everywhere...
When I started to lose hope after countless years of messaging to retro game forums, even tried contacting MVP software (the company who used to sell this game)
it looked like i was never gonna find it...
It became a bit of an obsession for me, as a kid i always wanted to play the full version but the game was first released in 1996, in 1999 MVP software declared the game abandonware and it got lost... What can i say, childhood memories are very important for me. Dang i miss the early 2000's!
In the meantime I managed to find a cracked version, this modified version allowed you to use special cheat-codes and you were free from the 30 day limit in the demo version. However, this was still not the full version and it was missing graphics, extra's and levels...
I Also found some very old versions of Debris, you could only open those with a dos emulator ...and they kind of suck compared to the latest version haha.
One day I bumped onto a seller on a secondhand app who, unbelievably but true, still had a final release CD of this game!
It's even compatible with windows 7, 8 and 10!
* End of backstory *
Because i had so much fun with this game i wanna try to clone it and maybe add some new stuff too :D
The first step of cloning this game was extracting the graphics and sounds.
Those files are not embedded inside the EXE-file of Debris, but they are stored inside *.DAT-files. Extracting the soundfiles from "sounds.dat" was easy, just drag the file into a nice little tool called ResHacker and bam! You have the soundfiles.
But what about the graphics? Those seem to be stored in "graphics.dat", dragging it into ResHacker just gives me an error... I had no clue what to do so i started a new topic on this forum asking for help. I recently got a lot of help from a great guy here on the PB forum, he managed to extract some files and helped me WITH EVERY DAT-FILE here:
viewtopic.php?f=7&t=76636
@infratec, I can't thank you enough for this!
Thanks to the help of @infratec I have all the graphics now. The backgrounds of the game are also extracted (old *.PCX-files i had to convert to *.BMP-files somehow).
Getting started working with some little code i made, the spaceships and enemy's seem to use exactly 32 little sprites, each sprite is a slight rotation with different lighting to give it a 3D effect (pretty nifty).
360° / 32 sprites = 11.25°, that value seems to be the golden value for this game, every ship, rock and alien that needs to move or rotate to a certain direction does this with steps of 11.25 degrees at a time, this was designed so that they could align the rotation with one of the 32 sprites:
I will reply on my own post with small updates and problems I'm bumping into for those who are interested or feel like helping me out :)
The files for this project will be uploaded to a google drive folder, for now it only contains everything i need to get started:
https://drive.google.com/drive/folders/ ... sp=sharing
And finally my code that I will update on the fly:
Code: Select all
; This is a copy of the game Debris32.
; It's programmed by TheAutomator (nickname) with the help of the purebasic forum members:
; https://www.purebasic.fr/english/viewtopic.php?f=16&t=76679&p=565219#p565219
; Search for "[TO DO]" to find code that is still under construction.
InitMouse() ; The functions here try to open DirectX (v3.0 With NT4.0 compatibility or v7.0 else).
InitSound() ; Returns nonzero if the mouse functions are availables, zero otherwise.
InitSprite() ; If it fails then DirectX is either not available or is too old be used.
InitKeyboard() ; Needs an IF-check! [TO DO]
; Declaring math constants:
#PI2 = #PI * 2
#Angle32 = 11.25 ; 360 degrees / 32 sprite images
#MaxAngle32 = 348.75
; Declaring game constants:
#Game_Width = 640
#Game_Height = 480
#Game_Center_X = 320
#Game_Center_Y = 240
; Opening a window for the game with a canvas to draw the graphics on:
OpenWindow(0, 0, 0, #Game_Width, #Game_Height, "Debris64", #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, #Game_Width, #Game_Height, 0, 0, 0)
; We want a lower framerate for the game, still need to implement deltatime! [TO DO]
SetFrameRate(24)
; Loading sprites and sounds:
LoadSprite(0, "graphics\ship\newship1.bmp")
LoadSprite(1, "graphics\backgrounds\" + Random(14) + ".bmp")
LoadSprite(2, "graphics\frame\3_FRAMESET.bmp")
LoadSound(0, "sounds\Sound_009.wav")
; Structures:
Structure Craft
ID.i ; Sprite ID
Size.i ; Sprite size
Index.i ; Sprite clipping index
Center.i ; Sprite center
X.f ; X-axis
Y.f ; Y-axis
Angle.f ; Angle
Accel.f ; Acceleration
Fric.f ; Friction
VX.F ; X-velocity
VY.F ; Y-velocity
AI.i ; Computer controlled?
EndStructure
Structure Rock
ID.i ; Sprite ID
Size.i ; Size of rock / mine
Index.i ; Sprite clipping index
Center.i ; Sprite center
X.f ; X-axis
Y.f ; Y-axis
VX.F ; X-velocity
VY.F ; Y-velocity
Type.i ; Type of rock / mine
MaxHits.i ; Maximum amount of hits before it explodes
Hits.i ; Amount of hits taken
EndStructure
; Creating objects for the game:
NewShip1.Craft
With NewShip1
\ID = 0
\X = #Game_Center_X
\Y = #Game_Center_Y
\Accel = 0.5
\Fric = 0.98
\Size = 32
\Center = 16
EndWith
; Functions:
Procedure ThrusterSound()
If SoundStatus(0) = #PB_Sound_Playing
If GetSoundPosition(0) > 2500
SetSoundPosition(0, 474)
EndIf
Else
PlaySound(0)
EndIf
EndProcedure
Procedure RotateCraft(*Ship.Craft)
If *Ship\Angle < 0
*Ship\Angle = #MaxAngle32
EndIf
If *Ship\Angle > #MaxAngle32
*Ship\Angle = 0
EndIf
*Ship\Index = *Ship\Angle / #Angle32
ClipSprite(*Ship\ID, *Ship\Size * *Ship\Index, 0, *Ship\Size, *Ship\Size)
EndProcedure
Procedure.f AngleDifference(*Aiming.craft, ObjectX, ObjectY)
DeltaX.f = ObjectX - *Aiming\X
DeltaY.f = ObjectY - *Aiming\Y
Target.f = ATan2(-DeltaY, DeltaX) ; Y must be negative and comes first in 'Atan2'
Target = Degree(Target)
Angle.f = Mod(Target - *Aiming\Angle, 360)
If Angle < -180
Angle + 360
ElseIf Angle > 180
Angle - 360
EndIf
ProcedureReturn Angle
EndProcedure
Procedure.f Distance(*Aiming.craft, ObjectX, ObjectY)
DeltaX.f = ObjectX - *Aiming\X
DeltaY.f = ObjectY - *Aiming\Y
ProcedureReturn Sqr(DeltaX * DeltaX + DeltaY * DeltaY)
EndProcedure
Procedure RenderShip(*Ship.Craft)
*Ship\VX * *Ship\Fric
*Ship\VY * *Ship\Fric
*Ship\X + *Ship\VX
*Ship\Y + *Ship\VY
If *Ship\X < 0
*Ship\X = #Game_Width
ElseIf *Ship\X > #Game_Width
*Ship\X = 0
EndIf
If *Ship\Y < 0
*Ship\Y = #Game_Height
ElseIf *Ship\Y > #Game_Height
*Ship\Y = 0
EndIf
CX.f = *Ship\X-*Ship\Center
CY.f = *Ship\Y-*Ship\Center
DisplayTransparentSprite(*Ship\ID, CX , CY )
; Need to change this so it only draws more objects if necessary for speed! [TO DO]
DisplayTransparentSprite(*Ship\ID, CX - #Game_Width , CY )
DisplayTransparentSprite(*Ship\ID, CX + #Game_Width , CY )
DisplayTransparentSprite(*Ship\ID, CX , CY - #Game_Height )
DisplayTransparentSprite(*Ship\ID, CX , CY + #Game_Height )
DisplayTransparentSprite(*Ship\ID, CX - #Game_Width , CY - #Game_Height )
DisplayTransparentSprite(*Ship\ID, CX + #Game_Width , CY + #Game_Height )
DisplayTransparentSprite(*Ship\ID, CX - #Game_Width , CY + #Game_Height )
DisplayTransparentSprite(*Ship\ID, CX + #Game_Width , CY - #Game_Height )
EndProcedure
; Main loop:
RotateCraft(@NewShip1) ; Must do this once before we render the ships!
Repeat
ExamineMouse()
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
NewShip1\Angle - #Angle32
RotateCraft(@NewShip1)
EndIf
If KeyboardPushed(#PB_Key_Right)
NewShip1\Angle + #Angle32
RotateCraft(@NewShip1)
EndIf
If KeyboardPushed(#PB_Key_Up)
NewShip1\VX + NewShip1\Accel * Sin(Radian(NewShip1\Angle))
NewShip1\VY - NewShip1\Accel * Cos(Radian(NewShip1\Angle))
ThrusterSound()
EndIf
If KeyboardPushed(#PB_Key_Down)
NewShip1\VX - NewShip1\Accel * Sin(Radian(NewShip1\Angle))
NewShip1\VY + NewShip1\Accel * Cos(Radian(NewShip1\Angle))
ThrusterSound()
EndIf
Dist.f = Distance(@NewShip1, MouseX(), MouseY())
If Dist < 100
Diff.f = AngleDifference(@NewShip1, MouseX(), MouseY())
If Diff > 6
NewShip1\Angle + #Angle32
RotateCraft(@NewShip1)
ElseIf Diff < -6
NewShip1\Angle - #Angle32
RotateCraft(@NewShip1)
EndIf
If Dist < 50
NewShip1\VX - NewShip1\Accel * Sin(Radian(NewShip1\Angle))
NewShip1\VY + NewShip1\Accel * Cos(Radian(NewShip1\Angle))
ThrusterSound()
ElseIf Dist < 300
NewShip1\VX + NewShip1\Accel * Sin(Radian(NewShip1\Angle))
NewShip1\VY - NewShip1\Accel * Cos(Radian(NewShip1\Angle))
ThrusterSound()
EndIf
EndIf
DisplaySprite(1, 0, 0) ; Stars overlay [TO DO]
RenderShip(@NewShip1)
DisplayTransparentSprite(2, MouseX()-7, MouseY()-6)
StartDrawing(ScreenOutput())
DrawText(50, 50, "Angle: " + Diff)
DrawText(50, 70, "Distance: " + Dist)
StopDrawing()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)