11-18-2022, 03:10 PM
(This post was last modified: 11-18-2022, 04:56 PM by James D Jarvis.)
Mini-Monster-Mixer v0.1 generates a sprites sheet of 40 monster sprites at 64x64 pixels.
A source image of parts (included in the program code) has pieces that are randomly selected and recolored to generate the final images.
Press c or s to save the currently displayed sprites sheet to the clipboard if you wish. (to be pasted into any paint program afterward).
A source image of parts (included in the program code) has pieces that are randomly selected and recolored to generate the final images.
Press c or s to save the currently displayed sprites sheet to the clipboard if you wish. (to be pasted into any paint program afterward).
Code: (Select All)
'Mini-Monster-Mixer v0.1
'By James D. Jarvis November 2022
'This program uses BASIMAGE coded by Dav for QB64GL 1.4, MAY/2020
'
'generate a sprite sheet of monsters
'each is 64 by 64 pixels but code here can be modified to change that
'
'press c or s to save a sprite sheet to the clipboard so you can paste it into a paint program
'and save is whatever format you desire
'pres <esc> to quit
'
'License: Share sprite sheets as long as they include generated credit bar in image
'any programs using original code or graphics from source or generated by program
' please include the following (or equivalent) line somwhere in comments and documentation:
'Includes Art and/or Code from Mini-Monster-Mixer v0.1 created by James D. Jarvis
'
Randomize Timer
Dim Shared ms&
ms& = _NewImage(512, 360, 32)
Screen ms&
_Title "Mini-Monster-Mixer V0.1"
Dim Shared part&
Dim Shared kk1 As _Unsigned Long
Dim Shared kk2 As _Unsigned Long
Dim Shared kk3 As _Unsigned Long
Dim Shared kk4 As _Unsigned Long
Dim Shared clr~&
part& = BASIMAGE1&
Type critterbody_type
head As Integer
arm As Integer
torso As Integer
leg As Integer
k1 As _Unsigned Long
k2 As _Unsigned Long
k3 As _Unsigned Long
k4 As _Unsigned Long
End Type
monster_limit = 40
Dim Shared mlook(monster_limit) As critterbody_type
_Source part&
'read the colors from the color reference bar whichever color is in the top left corner will be transparent
clr~& = Point(0, 0) 'find background color of image
kk1 = Point(0, 1): kk2 = Point(0, 2): kk3 = Point(0, 3): kk4 = Point(0, 4)
_Dest part&
Line (0, 0)-(0, 4), clr~& 'erase the color reference bar from the bit map
_ClearColor clr~&, ms& 'set background color as transparent
_ClearColor clr~&, part&
_Source ms&
_Dest ms&
Do
Cls
mmx = 0: mmy = 0
For m = 1 To monster_limit
'create a new set of monster sprites
'included image source has 16 options for head,arms,torso, and legs
mlook(m).head = Int(1 + Rnd * 16)
mlook(m).arm = Int(1 + Rnd * 16)
mlook(m).torso = Int(1 + Rnd * 16)
mlook(m).leg = Int(1 + Rnd * 16)
'generating new colors for this specific monstewr sprite
kr = Int(Rnd * 150 + 105): kg = Int(Rnd * 150 + 105): kb = Int(Rnd * 150 + 105)
kr2 = Int(kr / 2): kg2 = Int(kg / 2): kb2 = Int(kb / 2)
kr3 = Int(kr2 / (1.2 + Rnd * 3)): kg3 = Int(kg2 / (1.2 + Rnd * 3)): kb3 = Int(kb2 / (1.2 + Rnd * 3))
mlook(m).k1 = _RGB32(kr, kg, kb)
mlook(m).k2 = _RGB32(kr2, kg2, kb2)
mlook(m).k3 = _RGB32(kr3, kg3, kb3)
mlook(m).k4 = _RGB32(Int(Rnd * 220 + 33), Int(Rnd * 210 + 33), Int(Rnd * 200 + 33))
draw_monster mmx, mmy, m, 3
mmx = mmx + 64
If mmx >= _Width Then
mmx = 0
mmy = mmy + 64
End If
Next m
md$ = "Monster Sprite Sheet generated " + Date$ + " at " + Time$
md2$ = "Using Mini-Monster-Mixer V0.1 by James D. Jarvis"
_PrintString (0, 321), md$
_PrintString (0, 337), md2$
Do
_Limit 60
kk$ = InKey$
Loop Until kk$ <> ""
If kk$ = "C" Or kk$ = "c" Or kk$ = "S" Or kk$ = "s" Then
_ClipboardImage = ms&
_Delay 0.3
Locate 1, 1: Print "Sprite Sheet Saved to Clipboard"
Sleep 3
End If
Loop Until kk$ = Chr$(27)
_FreeImage part&
System
Sub draw_monster (Mx, my, mid, scale)
'generate a monster image from source sprite sheet part& and render to the programs main screen ms&
tempi& = _NewImage(32, 32, 32)
'tempi& creates a temporary one sprite image for rendering
_ClearColor clr~&, tempi&
_Dest tempi&
Cls
hs = Int(Rnd * (scale * 2))
_PutImage (0, 0)-(31, 31), part&, tempi&, ((mlook(mid).leg - 1) * 32, 96)-((mlook(mid).leg - 1) * 32 + 31, 96 + 31)
_PutImage (0, 0)-(31, 31), part&, tempi&, ((mlook(mid).arm - 1) * 32, 32)-((mlook(mid).arm - 1) * 32 + 31, 32 + 31)
_PutImage (0 - Int(hs * .8), 0)-(31 + Int(hs * .8), 31), part&, tempi&, ((mlook(mid).torso - 1) * 32, 64)-((mlook(mid).torso - 1) * 32 + 31, 64 + 31)
_PutImage (0 - hs, 0)-(31 + hs, 31), part&, tempi&, ((mlook(mid).head - 1) * 32, 0)-((mlook(mid).head - 1) * 32 + 31, 31)
_Source tempi&
'repaint source image with generate color values for new monster sprite
For y = 0 To 31
For x = 0 To 31
Select Case Point(x, y)
Case kk1
PSet (x, y), mlook(mid).k1
Case kk2
PSet (x, y), mlook(mid).k2
Case kk3
PSet (x, y), mlook(mid).k3
Case kk4
PSet (x, y), mlook(mid).k4
End Select
Next x
Next y
'generated image in tempi& is rendered to ms& as a 64 by 64 sprite
_PutImage (Mx, my)-(Mx + 63, my + 63), tempi&, ms&
_Source ms&
_Dest ms&
_FreeImage tempi&
End Sub
'================================
'PNG file saved using BASIMAGE1&
'================================
Function BASIMAGE1& 'mparts32a.png
v& = _NewImage(512, 128, 32)
Dim m As _MEM: m = _MemImage(v&)
A$ = ""
A$ = A$ + "haIkM6PTSS235M^TiBfGbIG_Ma6I516\AB4k7EmVTHkP0QP?PMji?oi?om?0000`SR]DfU1hHNmZofYA^f[FVRbF[XmSTAjW>cndolc?o7AmmPSY4g[9kb5l"
A$ = A$ + "maIkSZCAG^OJf_WniA=F#FSoD\A6f_XWE#KKmimX^;Se\Ro:YIi;Te3MMZElO[_gMQGo[CFBDaMbH?Ik]E<XWnnXZo[:g5mWcdfE;UEMoYHO]VS^oOTJoBk:"
A$ = A$ + "OODnP8]o_SinjoO]fl?TGc\7keZMGWl>6H[>MDb;=7Mo<[nNAdG\XgmY_?Vi0LDk_GJoJmnS`cfO[fgS>_7]7bHnIk_KUOeBW9_>cH5UhMI\_gnlEanUfM;k"
A$ = A$ + "7eJM\638bml_Fm?:moFfOfU1[nf5]NYmefeWaPoKheO9bjZEmg[nQbjF_coa[a3\dnUn1_lmjjF[fO_R1N[_oNn^FOf_H_j]]7MniGFlEoicmlimL[ZgnonJ"
A$ = A$ + "lLOPZUldWOT]SZ<dJ=#AYoG\Ud^AioU[a#JobJClffAKoBO?Mi#WdffSm0XV][E6l8^kmhlk][lHnHcmkc]L>gFjONDFf?VK]mRcgm2?cfoR?hcjlkH0oSmJ"
A$ = A$ + "GomFoGf>KmnIgF[WKeAY?WCV?c7g:iM\Wfo[WCD4U1Y^S>N<Bmo\foSl7oY]mmHmoeR1?:n?Rm2_UmmaogNmoNf^K=o?ikmL<?K]omSe:m7NFoOkce[9dom0"
A$ = A$ + "bJ]VbSiUM7=UEi`_HoGomcnLOZo9S9mb78g3l<fkogfnMo#_Kgo\mhcnoAk3R:V_MK#LnnJS1nkkS[=8choE`nbHPXSm\\M4UQ\eoOG>f7k[k34U_?jaOUkU"
A$ = A$ + "ManbbbFbkWkAmn>:mmbSkU]UYJnoBIakh0_[_mj7RZo_T?k_7[n_U?8jWcjEag[K3RN>0A7o_:fG7oWAM?jioTinoGcNe:?A4gUaH0IJoNdomL^7eJceYXd2"
A$ = A$ + "bjgh[e_cUX;7AeO[6I<nWEI83K[mmIe6Tm_am\Sk]dNR\^WAlGF?oOF]1JoOTnn\6oE?g_873dJ?8Ta3A]g3jkgUNn7geOc][6IYkD8;mGhiB]Hn<j;TeHMF"
A$ = A$ + "c18J]oEI>`AcCEoGG6d9dm10lVFJ<?1mWgeeWmOoKbT\^oWbOGMFcocjg:dMZn30l\IUFo?l<9[koPDo_lnRfKTjoFnP\KC00N6XejAk7N:8eiU_6Yf?0000"
A$ = A$ + "4?jkm3g380000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000PXie[ofme:C[#I"
A$ = A$ + "NTbN6i9000`ZbVNG_JN5MO?eoeYN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f?;\f3jXeQ]:;iDo]ooT"
A$ = A$ + "WXlmFno8W3lC<nOUH5dob^<T=?ij>ll`B3:;moeXnoimU?3onniS4oL0b^M1000OiY[oOT?87KojSi04W_0]O00hYaCBc_FM?gmMock3Afn5000000000000"
A$ = A$ + "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000PeRG_NUNI00000b1V70"
A$ = A$ + "000#\XCAIg==o=niWO<O=Ko2000`MU=MFM::]gJjnN[o_EUeDkLNk3dci:niPIGoSbnI`8aFAdG8[iO3`:#dSi2oBA[?JmoFJnbGmafOZmgBogkHb<eo?Zn7"
A$ = A$ + "YmSdWGR_e_NdilP]hl=:YbWSXm_P<N;JK_Jf?SiNWEo_\9[nojfN[dM_mGZeKQ_eKdoe]3enL4aNI\o77eggCkg:N?jn25]Oil0RB3D>_SF7k^Jo=NZmoTnj"
A$ = A$ + "N?^Weo<V3`AYkLkOFkkoEen_jhbXoOL<fZ<70?m1ej[7iH0K8ek:9doSanbfkJOf;:aho>^knaO:7k^Zog[f_GnPNCU[e7O`[>dOV_NL9Uajn;ekcNOoWAiD"
A$ = A$ + "jKc`oG[mXfWW_o__nFNe7LdnnNdo_<gGi[mL>?8cmo?Kmg\]o6AgokMLfcBoG[[F>F]nlF]9cZ<9k[E;Y?WG]o7]nciJc?GcoXe_[>fd<dn]f_f[hkSboG;>"
A$ = A$ + "dcHmFemIN]G]\4Q^O]H9foOdo[mi8\O?7cCoO_7g[jH]nmcfgXCUnLeh\JTm`nePZ7oimiV[=]eokM<^I\fTcn\n;7?^lM^bHdIho[5?J]nC_63HD]EOV7Jn"
A$ = A$ + "goUJm]m\?_5I]ooeFOSL>8NGoKIo8lmbb#]?7QmkiHAgn?CoP>OJmiA^fcD>TjkjS[KomLN0m]occGoo\kk_dg=SH_AOFoVYfOFnoJne87oITjET[o?:KFJk"
A$ = A$ + "gB[`no_QNoomfN5K:7OcZ\h]>dAf?2o#dmoZef;]OTco[VoO6co[FLD[?gceNVfXFjGBO^EN[W7`<loILoWe[o_glOd[OTH`NWCA=]oc_foNFoilf3PJJJm>"
A$ = A$ + "nc<e4?BS=6=hl^o;[dno_QNO7mfNBkJ5[5aJoG1k_QUMRDo?Ckk]o_T7cFoODOD;]Oii;__V?aSm28bfocXoGBnmka[_m1XhoWmHbajokcFedomXlHU_A\g7"
A$ = A$ + "]dhSJoGF1m7IKNdf<kjOff_hgkiHgAk7]o_V^YlcFWkZm=JYOYeg>JMncNNjA[o[YFMEjGjM?j_BiZeJPVQfO[jI_7kZaPGEogShRJj_NeFKe^fkam`n[PnS"
A$ = A$ + ">IeN<ki3ebNcH<G\oH]k7ML?83mOm[]ZoFOWcHC[kg_>9?OD?C>FjMN_?PjD[OC0Slli=3\V7`\l5FmWj9n[egoK`nWI=fe>g<ePJef6aNQGc?Odil\LD;=k"
A$ = A$ + "inIUTnnJWc;k?jim\ngjLcdnF_Ndi^;noJeE?Zg]dn?J<8ieiAmgJ]eA\Nk=Jm\06imn\FICo<2>[h]JYA^V_=kKml>dkmOgSk7oAgc7?JkeiOYO]^oM[ci1"
A$ = A$ + "S4?hIi00000n>iO0JAWJ%%%0"
btemp$ = ""
For i& = 1 To Len(A$) Step 4: B$ = Mid$(A$, i&, 4)
If InStr(1, B$, "%") Then
For C% = 1 To Len(B$): F$ = Mid$(B$, C%, 1)
If F$ <> "%" Then C$ = C$ + F$
Next: B$ = C$: End If: For j = 1 To Len(B$)
If Mid$(B$, j, 1) = "#" Then
Mid$(B$, j) = "@": End If: Next
For t% = Len(B$) To 1 Step -1
B& = B& * 64 + Asc(Mid$(B$, t%)) - 48
Next: X$ = "": For t% = 1 To Len(B$) - 1
X$ = X$ + Chr$(B& And 255): B& = B& \ 256
Next: btemp$ = btemp$ + X$: Next
btemp$ = _Inflate$(btemp$)
_MemPut m, m.OFFSET, btemp$: _MemFree m
BASIMAGE1& = _CopyImage(v&): _FreeImage v&
End Function