Warning! Squadrons of pixel craft are heading towards FB!!

Post your FreeBASIC source, examples, tips and tricks here. Please don’t post code without including an explanation.
Adigun A. Polack
Posts: 231
Joined: May 27, 2005 15:14
Contact:

Warning! Squadrons of pixel craft are heading towards FB!!

Post by Adigun A. Polack »

Yep, you heard right!! ;)

Brace yourself for quite a first in the world of FreeBASIC: squadrons and squadrons of custom pixel-based ships that will soon be yours for the taking, free to use the creation of your own games in FB. Yes, I am doing what I can to revive this FreeBASIC gaming community... with stuff like this!!! (^-^)v !!

For example, this all-new code from me lets you check out my own custom algorithms that I made which enables you to create a randomized pixel craft with a physical size of just almost 20x20 pixels each!!! Check it out:

Code: Select all

'======================================================================
' P i x e l   C r a f t   D e s i g n e r   ( F r e e B A S I C )
'======================================================================
' For 8-bit color modes.   The special custom version for 15- to 32-bit
' color graphics modes is gonna be built-in EXCLUSIVELY into the new
' AFlib2 Remixed!!!
'
' Presented by Adigun Azikiwe Polack.
' (c)2008 Adigun Azikiwe Polack.  All Rights Reserved.
'======================================================================


Declare Sub GeneratePalette_Rel

Declare Sub MakeGradient ( Byval startcol as Integer, _
                           Byval r1 as Integer, Byval g1 as Integer, _
                           Byval b1 as Integer, _
                           Byval endcol as Integer, _
                           Byval r2 as Integer, Byval g2 as Integer, _
                           Byval b2 as Integer)

Declare Sub CreatePixelCraft_256color ( Byval x as integer, _
                                        Byval y as integer, _
                                        Byval ColSpread as integer, _
                                        Byval Size_x as integer, _
                                        Byval Size_y as integer )


Screenres 400, 300, 8, 0, 0

Dim rand as integer
GeneratePalette_Rel

NextPattern:
rand = int(rnd(1)* 155) + 101
Line(0, 0)-(400, 300), 1, bf
For ShipLine_x as Integer = 0 to 28 step 1
  For ShipLine_y as Integer = 0 to 14 step 1
    CreatePixelCraft_256color (ShipLine_x * 20) + 1, (ShipLine_y * 20) + 1, 0, 16, 17
  Next
Next
sleep
IF multikey(&h01) then end else Goto NextPattern




Sub CreatePixelCraft_256color ( Byval x as integer, _
                                Byval y as integer, _
                                Byval ColSpread as integer, _
                                Byval Size_x as integer, _
                                Byval Size_y as integer )
                                
If Size_x > 16 then Size_x = 16
If Size_y > 17 then Size_y = 17

Size_x /= 2
Size_y += 11

x -= 1
y -= 2

Dim as Integer ColRandom, OuterShell, Start

Start = (Size_x + 2)
For Vert as Integer = 0 to Size_y
  Outershell = 1
  If Vert < (Size_y / 2.1) then
    Start -= 1: If Start < 0 then Start = 0
  else
    Start += 2
  End if
  For Horiz as Integer = Start to Size_x
    If OuterShell > 0 then
      If (int(rnd(1) * 70) + (1 + Vert)) > 35 - (Vert \ 2) or Vert = 0 and Horiz = (Size_x) or Horiz = (Size_x - 1) then
        Pset (Horiz + x, Vert + y), 0
        Pset (((Size_x - Horiz) + (Size_x + 1)) + x, Vert + y), 0
        OuterShell = 0
      End if
    Else
      ColRandom = int(rnd(1) * 7) + 1
      ColRandom += 1
      If ColRandom > 8 then ColRandom = int(rnd(1) * 4) + int(rnd(1) * 4)
      Select Case as const ColRandom
        Case 1:
          Pset (Horiz + x, Vert + y), 23 + (Colspread * 16)
          Pset (((Size_x - Horiz) + (Size_x + 1)) + x, Vert + y), 19 + (Colspread * 16)
        Case 2:
          Pset (Horiz + x, Vert + y), 24 + (Colspread * 16)
          Pset (((Size_x - Horiz) + (Size_x + 1)) + x, Vert + y), 20 + (Colspread * 16)
        Case 3:
          Pset (Horiz + x, Vert + y), 25 + (Colspread * 16)
          Pset (((Size_x - Horiz) + (Size_x + 1)) + x, Vert + y), 21 + (Colspread * 16)
        Case 4:
          Pset (Horiz + x, Vert + y), 26 + (Colspread * 16)
          Pset (((Size_x - Horiz) + (Size_x + 1)) + x, Vert + y), 22 + (Colspread * 16)
        Case 5:
          Pset (Horiz + x, Vert + y), 28 + (Colspread * 16)
          Pset (((Size_x - Horiz) + (Size_x + 1)) + x, Vert + y), 24 + (Colspread * 16)
        Case 6:
          Pset (Horiz + x, Vert + y), 31 + (Colspread * 16)
          Pset (((Size_x - Horiz) + (Size_x + 1)) + x, Vert + y), 27 + (Colspread * 16)
        Case 7:
          Pset (Horiz + x, Vert + y), 29 + (Colspread * 16)
          Pset (((Size_x - Horiz) + (Size_x + 1)) + x, Vert + y), 25 + (Colspread * 16)
        Case 8:
          Pset (Horiz + x, Vert + y), 0 + (Colspread * 16)
          Pset (((Size_x - Horiz) + (Size_x + 1)) + x, Vert + y), 0 + (Colspread * 16)
      End Select
    End if
  Next
Next

End Sub



'_________________________________________________________________________
Sub GeneratePalette_Rel

'Special thanks to Richard Eric M. Lope (Relsoft) for his classic 256-color
'palette which inspired me to do this exact custom emulation of this one
'indeed!!!  ^-^=b !

Dim as Integer SetupPalette, PaletteArrange
Dim as Single RGBchannel(1 to 3), Channel_Target, PalSet

Palette
For SetupPalette = 0 to 15 step 1
  Select Case as Const SetupPalette
    Case 0: Channel_Target = 0
    Case 1: Channel_Target = 5
    Case 2: Channel_Target = 8
    Case 3: Channel_Target = 11
    Case 4: Channel_Target = 14
    Case 5: Channel_Target = 17
    Case 6: Channel_Target = 20
    Case 7: Channel_Target = 24
    Case 8: Channel_Target = 28
    Case 9: Channel_Target = 32
    Case 10: Channel_Target = 36
    Case 11: Channel_Target = 40
    Case 12: Channel_Target = 45
    Case 13: Channel_Target = 50
    Case 14: Channel_Target = 56
    Case 15: Channel_Target = 63
  End Select
  For PalSet = 1 to 3
    RGBchannel(PalSet) = Channel_Target
  Next
  Palette 16 + SetupPalette, RGBchannel(1) + (256 * RGBchannel(2)) + (65536 * RGBchannel(3))
Next
For PaletteArrange = 2 to 15 step 1
  For SetupPalette = 0 to 15 step 1
    Select Case as Const SetupPalette
      Case 0: Channel_Target = 0
      Case 1: Channel_Target = 4
      Case 2: Channel_Target = 8
      Case 3: Channel_Target = 12
      Case 4: Channel_Target = 16
      Case 5: Channel_Target = 21
      Case 6: Channel_Target = 25
      Case 7: Channel_Target = 29
      Case 8: Channel_Target = 33
      Case 9: Channel_Target = 37
      Case 10: Channel_Target = 42
      Case 11: Channel_Target = 46
      Case 12: Channel_Target = 50
      Case 13: Channel_Target = 54
      Case 14: Channel_Target = 58
      Case 15: Channel_Target = 63
    End Select
    Select Case as Const PaletteArrange
      Case 2:
        RGBchannel(1) = Channel_Target
        RGBchannel(2) = 0
        RGBchannel(3) = 0
      Case 3:
        RGBchannel(1) = 0
        RGBchannel(2) = 0
        RGBchannel(3) = Channel_Target
      Case 4:
        RGBchannel(1) = 0
        RGBchannel(2) = Channel_Target
        RGBchannel(3) = 0
      Case 5:
        RGBchannel(1) = Channel_Target
        RGBchannel(2) = 0
        RGBchannel(3) = Channel_Target
      Case 6:
        RGBchannel(1) = 0
        RGBchannel(2) = Channel_Target
        RGBchannel(3) = Channel_Target
      Case 7:
        RGBchannel(1) = Channel_Target
        RGBchannel(2) = Channel_Target
        RGBchannel(3) = 0
      Case 8:
        RGBchannel(1) = Channel_Target
        RGBchannel(2) = int(Channel_Target / 2)
        RGBchannel(3) = 0
      Case 9:
        RGBchannel(1) = Channel_Target
        RGBchannel(2) = 0
        RGBchannel(3) = int(Channel_Target / 2)
      Case 10:
        RGBchannel(1) = 0
        RGBchannel(2) = int(Channel_Target / 2)
        RGBchannel(3) = Channel_Target
      Case 11:
        RGBchannel(1) = Channel_Target
        RGBchannel(2) = int(Channel_Target / 1.5)
        RGBchannel(3) = int(Channel_Target / 2)
      Case 12:
        RGBchannel(1) = Channel_Target
        RGBchannel(2) = int(Channel_Target / 2)
        RGBchannel(3) = int(Channel_Target / 2)
      Case 13:
        RGBchannel(1) = int(Channel_Target / 1.4)
        RGBchannel(2) = int(Channel_Target / 2)
        RGBchannel(3) = 0
      Case 14:
        RGBchannel(1) = 0
        RGBchannel(2) = 0
        RGBchannel(3) = 0
      Case 15:
        RGBchannel(1) = (int(Channel_Target / 2) + 32)
        RGBchannel(2) = Channel_Target
        RGBchannel(3) = 0
    End Select
    Palette (PaletteArrange * 16) + SetupPalette, RGBchannel(1) + (256 * RGBchannel(2)) + (65536 * RGBchannel(3))
  Next
Next

End Sub



'_________________________________________________________________________
Sub MakeGradient (Byval startcol as Integer, _
                  Byval r1 as Integer, Byval g1 as Integer, _
                  Byval b1 as Integer, _
                  Byval endcol as Integer, _
                  Byval r2 as Integer, Byval g2 as Integer, _
                  Byval b2 as Integer)

'This command makes a gradient color by interpolating the RGB values of
'the first color index (startcol) and the second (endcol) by the number of
'colors.

Dim as Single R, G, B
Dim as Single Rstep, Gstep, Bstep
Dim as Single col, cols

If r1 <= -24 then r1 = -24
If g1 <= -24 then g1 = -24
If b1 <= -24 then b1 = -24
If r2 <= -24 then r2 = -24
If g2 <= -24 then g2 = -24
If b2 <= -24 then b2 = -24

If r1 >= 63 then r1 = 63
If g1 >= 63 then g1 = 63
If b1 >= 63 then b1 = 63
If r2 >= 63 then r2 = 63
If g2 >= 63 then g2 = 63
If b2 >= 63 then b2 = 63

If startcol > endcol then
  Swap endcol, startcol
  Swap r2, r1
  Swap g2, g1
  Swap b2, b1
End if

R = r1
G = g1
B = b1
cols = (endcol - startcol + 1)
Rstep = (r2 - r1 + 1) / cols
Gstep = (g2 - g1 + 1) / cols
Bstep = (b2 - b1 + 1) / cols
For col = startcol TO endcol
  R = R + Rstep
  G = G + Gstep
  B = B + Bstep
  If R > 63 then R = 63
  If R < 0 then R = 0
  If G > 63 then G = 63
  If G < 0 then G = 0
  If B > 63 then B = 63
  If B < 0 then B = 0
  Palette col, (65536 * (fix(B)) + (256 * fix(G)) + fix(R))
Next col

End Sub
You know, the MAIN inspiration that led me program my own custom algo in FB indeed came simply from Dave Bollinger’s outstanding tutorial on how Pixel Spaceships were first made, shown right here. Only this time, I took the pixel craft to a WHOLE new level, as the ships themselves are created using mirrored line upon every random-sized mirrored line and going down the columns a bit to draw them, making for literally millions and millions of custom and even damn slicker-looking ships!!! :D

And even better news is that I have created this specialized version entitled the “<i>Shmup Pixel Craft Generator</i>”, which touches up on this subject and more!! Created using both FB and the new AFlib2 Remixed and you can even generate and save your own custom true-color Pixel Craft creations to individual .BMP sprite sheets... download it here:
...and get started!!!

Image Image

Thank you all so very much, and see you back with your thoughts. (^-^)v !
Last edited by Adigun A. Polack on Feb 23, 2008 6:37, edited 2 times in total.
relsoft
Posts: 1767
Joined: May 27, 2005 10:34
Location: Philippines
Contact:

Post by relsoft »

That is one very cool procedural generation of ships dude! Amazing!
Dr_D
Posts: 2451
Joined: May 27, 2005 4:59
Contact:

Post by Dr_D »

Yeah. That's pretty crazy man. You could make like insects with it too, from the looks of it.
Ryan
Posts: 695
Joined: Jun 10, 2005 2:13
Location: Louisville, KY
Contact:

Post by Ryan »

hah Thanks so much for posting this! Now if you can just get one to make people w/ 2 walking frames and one standing frame in each direction. ^_^
notthecheatr
Posts: 1759
Joined: May 23, 2007 21:52
Location: Cut Bank, MT
Contact:

Post by notthecheatr »

Wow, that's brilliant!
Frank Dodd
Posts: 444
Joined: Mar 10, 2006 19:22

Post by Frank Dodd »

Very clever, it would be nice to be able to easily scale up the elements too
Lachie Dazdarian
Posts: 2338
Joined: May 31, 2005 9:59
Location: Croatia
Contact:

Post by Lachie Dazdarian »

This is really cool. I just might end up using this routine.

P.S.

Adigun, what's the current email address you are using?
Adigun A. Polack
Posts: 231
Joined: May 27, 2005 15:14
Contact:

Thank you, thank you!! ;) !

Post by Adigun A. Polack »

Thank you so much everybody (especially you as well, my awesome men Dr_D, rel, and Lachie!! ^-^=b ! ) for your splendidly constructive and supportive comments... I *really* appreciate them very much!!!

And Frank Dodd, you wrote:
Very clever, it would be nice to be able to easily scale up the elements too
...with which I took your advice to heart, in that I actually just tweaked my own custom programming a little bit to let users scale their ships up and down, creating you some bullets, missiles, and even some options to go as well!!! ;) Have a look:

Image

...plus it even lets you preview the transparency color before saving to a .BMP file:

Image

And Lachie, I do have 2 e-mail addresses: a Netzero account and a more recent Gmail account... and I do use them both. ;) I will tell you more about that by e-mail a little later.

Right now though, all of you, here is my update to Shmup Pixel Craft Generator which is ver. 2008-02-23, so please check the first post of this thread for a download of it, ok?

Thank you all so much once again, and give me some feedback on the update, guys!! ^-^ !
anonymous1337
Posts: 5494
Joined: Sep 12, 2005 20:06
Location: California

Post by anonymous1337 »

This is crazy awesome O.O;;
phycowelder
Posts: 74
Joined: Dec 19, 2007 6:55

Post by phycowelder »

this is truly awesome man!
inventive and ingenious
Lachie Dazdarian
Posts: 2338
Joined: May 31, 2005 9:59
Location: Croatia
Contact:

Post by Lachie Dazdarian »

Hmmm....I think I sent you an email some 15 days ago to the netzero account, and I can't find your reply to it, although I have a vague memory of it. Oh well, I'll wait that email from you.

And very nice update. Is it possible for the routine to support even larger sprites, and perhaps to allow more varied designs (i.e. bug-like)?
KristopherWindsor
Posts: 2428
Joined: Jul 19, 2006 19:17
Location: Sunnyvale, CA
Contact:

Post by KristopherWindsor »

Lachie Dazdarian wrote:I can't find your reply to it.
Yahoo has a mail search option. ;-)
Lachie Dazdarian
Posts: 2338
Joined: May 31, 2005 9:59
Location: Croatia
Contact:

Post by Lachie Dazdarian »

Which I used. Like I said, this is odd, because I seem to remember that I got a reply which now is inexistent. Anyway, no problems now. A contact has been established! :P
Merick
Posts: 1038
Joined: May 28, 2007 1:52

Post by Merick »

You know, the ships made by this make me think of the old Sinistar arcade game
Frank Dodd
Posts: 444
Joined: Mar 10, 2006 19:22

Post by Frank Dodd »

Merick wrote:You know, the ships made by this make me think of the old Sinistar arcade game
Yes I agree, it has that vert shooter retro game look that makes me think of the classics like Uridium.
Post Reply