Cloning DEBRIS32 game
- TheAutomator
- Enthusiast
- Posts: 112
- Joined: Tue Dec 01, 2020 8:33 pm
Re: Cloning DEBRIS32 game
it's a cool project!
but for now a little overkill, i'm also trying to make everything look the same,
a 3D look effect is not going to be accurate and why install a complete render engine if the sprites are already at hand :)
but for now a little overkill, i'm also trying to make everything look the same,
a 3D look effect is not going to be accurate and why install a complete render engine if the sprites are already at hand :)
Re: Cloning DEBRIS32 game
Have you seen my additions to
viewtopic.php?f=7&t=76636
Now you should have all pictures of the game.
viewtopic.php?f=7&t=76636
Now you should have all pictures of the game.
- TheAutomator
- Enthusiast
- Posts: 112
- Joined: Tue Dec 01, 2020 8:33 pm
Re: Cloning DEBRIS32 game
Oh i didn't notice (was on a second page), i replied over there with a little code :pinfratec wrote:Have you seen my additions to
viewtopic.php?f=7&t=76636
:?:
Now you should have all pictures of the game.
I'm gonna extract everything today and update the drive folder and description! :)
Re: Cloning DEBRIS32 game
I use png because in png is already transparency included.
You don't need set a transparence color.
I use IrfanView and save the images as png with 'save transparent color' enabled,
but disabled 'save transparence as alpha-channel'.
Then I can simply use DisplayTransparentSprite() (after LoadSprite() of course)
You don't need set a transparence color.
I use IrfanView and save the images as png with 'save transparent color' enabled,
but disabled 'save transparence as alpha-channel'.
Then I can simply use DisplayTransparentSprite() (after LoadSprite() of course)
- TheAutomator
- Enthusiast
- Posts: 112
- Joined: Tue Dec 01, 2020 8:33 pm
Re: Cloning DEBRIS32 game
I noticed you don't even have to set that color with bmp's if you leave it black like the original graphics :)infratec wrote:I use png because in png is already transparency included.
You don't need to set a transparency color.
PNG uses an extra decoder so maybe it's a little slower, not sure..
- TheAutomator
- Enthusiast
- Posts: 112
- Joined: Tue Dec 01, 2020 8:33 pm
Re: Cloning DEBRIS32 game
@ricardo_sdl
I looked at your code today and noticed the actual angle was not snapped to the 11.25° angles but the sprite number was correct.
If the ship would need to fly forward it would need to do so in exactly the snapped angle that the sprite displays.
In the original debris game the ship also fly's in exactly that snapped angle.
If I use your code without modifications this would be a problem, for example:
The ship looks like it's at an angle of exactly 90°, but if you fly forward it doesn't always fly in a straight horizontal line.
why? Under the hood you still work with a 360° system, so the ship could look like it's in a 90° angle but in reality it's for example 92°.
If I want to implement delta time with the angle system that is needed for this project than I have no idea yet how to implement this..
Using ElapsedMilliseconds() like you did instead of SetFrameRate() gives me strange results...
Use an interval for ElapsedMilliseconds() at 31 or 32 milliseconds and it looks like it's exactly the same speed, use 33 and suddenly it's way slower??
So for now i use setframerate(),
The only thing that bothers me is that if you pressed the left or right to quickly, the ship it doesn't react..
The original game still reacts if you quickly press and release a button.
@STARGÅTE
I used your angle difference function and with some fiddling around (still a bit new to game graphics math) I found out how to use it properly! ..kinda :p
The main problem is that the ship wiggles when it's almost locked at it's target in AI-mode, it's also because of the angle snap system i'm afraid.
I think I managed to solve this with dif > 0.1 and dif < -0.1, but if you know a better way feel free to correct me :)
For everyone reading this:
I updated my code and also fully updated the folders in google drive.
All the graphics, all the sounds, everything is uploaded, updated and renamed to organize everything a little better.
To test my code you can download the new files from the link :)
I looked at your code today and noticed the actual angle was not snapped to the 11.25° angles but the sprite number was correct.
If the ship would need to fly forward it would need to do so in exactly the snapped angle that the sprite displays.
In the original debris game the ship also fly's in exactly that snapped angle.
If I use your code without modifications this would be a problem, for example:
The ship looks like it's at an angle of exactly 90°, but if you fly forward it doesn't always fly in a straight horizontal line.
why? Under the hood you still work with a 360° system, so the ship could look like it's in a 90° angle but in reality it's for example 92°.
If I want to implement delta time with the angle system that is needed for this project than I have no idea yet how to implement this..
Using ElapsedMilliseconds() like you did instead of SetFrameRate() gives me strange results...
Use an interval for ElapsedMilliseconds() at 31 or 32 milliseconds and it looks like it's exactly the same speed, use 33 and suddenly it's way slower??
So for now i use setframerate(),
The only thing that bothers me is that if you pressed the left or right to quickly, the ship it doesn't react..
The original game still reacts if you quickly press and release a button.
@STARGÅTE
I used your angle difference function and with some fiddling around (still a bit new to game graphics math) I found out how to use it properly! ..kinda :p
The main problem is that the ship wiggles when it's almost locked at it's target in AI-mode, it's also because of the angle snap system i'm afraid.
I think I managed to solve this with dif > 0.1 and dif < -0.1, but if you know a better way feel free to correct me :)
For everyone reading this:
I updated my code and also fully updated the folders in google drive.
All the graphics, all the sounds, everything is uploaded, updated and renamed to organize everything a little better.
To test my code you can download the new files from the link :)
Re: Cloning DEBRIS32 game
Angle to Sprite Index:
If the ship sprites are composed into a single sprite-/tilemap (with a height of one)
Simply extract the correct sprite with ClipSprite()
If each sprite loaded seperately into an array (srsly why would u do that?...) use it as the array index.
A more complete Example (only missing the sprite-/tilemap):
Angle and direction:
I dont know what debris does but if its not locked at those angles it most likely just adjusts the closest sprite to the direction.
Code: Select all
Procedure.i AngleToSpriteIndex(Angle.f)
Protected index.i
index = ((Angle - 5.625) / 11.25)
If index = 32
index = 0
EndIf
ProcedureReturn index
EndProcedure
Simply extract the correct sprite with ClipSprite()
Code: Select all
ClipSprite(sprite,AngleToSpriteIndex(Angle) * 32,0,32,32)
Code: Select all
AngleToSpriteIndex(Angle)
Code: Select all
EnableExplicit
UsePNGImageDecoder()
Procedure.i AngleToSpriteIndex(Angle.f)
Protected index.i
index = ((Angle - 5.625) / 11.25)
If index = 32
index = 0
EndIf
ProcedureReturn index
EndProcedure
Procedure.i RenderShip(X.f,Y.f,Sprite.i,Angle.f)
ClipSprite(sprite,AngleToSpriteIndex(Angle) * 32,0,32,32)
ZoomSprite(sprite,128,128)
DisplayTransparentSprite(sprite,X - 64,Y - 64)
ProcedureReturn
EndProcedure
Procedure.i Main()
Protected sprite.i
Protected rotation.f
If InitSprite()
If OpenWindow(0,0,0,640,480,#Null$,#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget)
If OpenWindowedScreen(WindowID(0),0,0,640,480)
SetFrameRate(60)
sprite = CatchSprite(#PB_Any,?ship,#PB_Sprite_AlphaBlending);<- load sprite-/tilemap!
Repeat
Repeat
Select WindowEvent()
Case #PB_Event_CloseWindow
Break 2
Case #Null
Break
EndSelect
ForEver
ClearScreen(#Null)
RenderShip(320,240,sprite,rotation)
rotation + 1
If rotation > 360
rotation = 0
EndIf
FlipBuffers()
ForEver
EndIf
CloseWindow(0)
EndIf
EndIf
ProcedureReturn #Null
EndProcedure
Main()
End
DataSection
ship:
;include ship sprite-/timemap
EndDataSection
I dont know what debris does but if its not locked at those angles it most likely just adjusts the closest sprite to the direction.
- TheAutomator
- Enthusiast
- Posts: 112
- Joined: Tue Dec 01, 2020 8:33 pm
Re: Cloning DEBRIS32 game
it never is rotated out of those angles @Mijikai.Angle and direction:
I dont know what debris does but if its not locked at those angles it most likely just adjusts the closest sprite to the direction.
gonna view your example now, thanks :)
about the loading into an array or constantly snipping into one big sprite, isn't the second option way slower and harder for a computer? i never used that tool for sprites because of that, it makes managing sprites a lot easier though.
Last edited by TheAutomator on Tue Feb 09, 2021 7:19 pm, edited 1 time in total.
Re: Cloning DEBRIS32 game
Uploading one vs. multiple texture to the gpu is faster.TheAutomator wrote:...about the loading into an array or constantly snipping into one big sprite, isn't the second option way slower and harder for a computer? i never used that tool for sprites because of that, it makes managing sprites a lot easier though.
Ideally you want to have as few of those transfers as possible.
For a small games this might not matter but it is good practise and often makes things easier anyway.
Some paper:
http://download.nvidia.com/developer/NV ... epaper.pdf
- TheAutomator
- Enthusiast
- Posts: 112
- Joined: Tue Dec 01, 2020 8:33 pm
Re: Cloning DEBRIS32 game
So i better merge the sprites into long rows or grids in a single picture then, okay, thanks for the tip!
@Mijikai, worked like a charm, using your sprite render function now. (made a long image from the ships, it's in the drive folder)
Going to update the code soon, busy days here unfortunately so i don't have much free time right now..
@Mijikai, worked like a charm, using your sprite render function now. (made a long image from the ships, it's in the drive folder)
Going to update the code soon, busy days here unfortunately so i don't have much free time right now..
- TheAutomator
- Enthusiast
- Posts: 112
- Joined: Tue Dec 01, 2020 8:33 pm
Re: Cloning DEBRIS32 game
UPDATE: move the mouse to the ship :p
Next step: bullets!
Next step: bullets!
Re: Cloning DEBRIS32 game
Use
as your first instruction.
Since the program is growing, you will run into trouble without it.
Code: Select all
EnableExplicit
Since the program is growing, you will run into trouble without it.
Re: Cloning DEBRIS32 game
Also use Enumerations / constants for your sprites and sounds.
It is easier to read
instead of
And for me (personally) it looks horrible if procedures are directly inside of the main code.
I place them above of the code.
Behind constants/enumerations and structures
But that's only my preferred coding.
It is easier to read
Code: Select all
DisplaySprite(#Ship, ...)
Code: Select all
DisplaySprite(0, ...)
I place them above of the code.
Behind constants/enumerations and structures
Code: Select all
EnableExplicit
#bla = 1
#blu = 2
Structure xyz
EndStructure
XIncludeFile "file.pbi"
Procedure X1()
Protected.i Va1
EndProcedure
;-Main
Define.i X, Y, Exit
Init()
OpenWindow()
Repeat
Until Exit
- TheAutomator
- Enthusiast
- Posts: 112
- Joined: Tue Dec 01, 2020 8:33 pm
Re: Cloning DEBRIS32 game
@infratec,
I will, it's only in it's early testing state :)
I will, it's only in it's early testing state :)