Essentially there is only one generic skeleton. In theory all you should have to do is type in the length, angle, angle limits and you have the skeleton of any animal with a backbone. The hard bit is the drawing the different faces and clothes.Boromir wrote:I never posted it because some features like building skeletons were less than user friendly.
Sprite and tile collision demo
-
- Posts: 3906
- Joined: Jan 01, 2009 7:03
- Location: Australia
Re: Sprite and tile collision demo
Re: Sprite and tile collision demo
You would need to use bones to control other element of your sprite such as cloaks, hair or tails. Creatures such as crabs or octopuses would need different skeletons. My bone system isn't awful but there is no bone length locking or mirroring. My editor is also missing a host of other functionality such as keyframe copying,simultaneous bone editing and vector graphics support.BasicCoder2 wrote:Essentially there is only one generic skeleton. In theory all you should have to do is type in the length, angle, angle limits and you have the skeleton of any animal with a backbone. The hard bit is the drawing the different faces and clothes.
-
- Posts: 3906
- Joined: Jan 01, 2009 7:03
- Location: Australia
Re: Sprite and tile collision demo
I suspect there is a lot of less than complete stuff out there. Problem is it is easier to write it all from the ground up than to try and add functionality to someone else's source code.Boromir wrote: My editor is also missing a host of other functionality such as keyframe copying,simultaneous bone editing and vector graphics support.
So in 3d graphics the strands hair or groups of strands of hair require finger-like rigging? Same with clothes? Something I didn't know or at least think about.
3D is out of my league and the octopus would have to be 3D unlike say a side or front/back view of a platform type stick figure.
Here I imagine two spider or octopus like legs.
You can click a joint with the mouse and rotate it using the A and D keys.
Of course I should add the angle limit values to restrict the joints positions.
Code: Select all
'some useful defines
Const Pi = 4 * Atn(1)
Dim Shared As Double TwoPi = 8 * Atn(1)
Dim Shared As Double RtoD = 180 / Pi ' radians * RtoD = degrees
Dim Shared As Double DtoR = Pi / 180 ' degrees * DtoR = radians
sub drawLine(x1 As Integer,y1 As Integer,x2 As Integer,y2 As Integer,size As Integer,c As ulong)
var dx = x2 - x1
var dy = y2 - y1
if dx = 0 andalso dy=0 then
circle (x1, y1), size, c, , , , f
elseif abs(dx) > abs(dy) then
var m = dy / dx
for x as Integer = x1 To x2 step sgn(dx)
circle (x,m * (x - x1) + y1), size, c, , , , f
next
else
var m =dx / dy
for y as Integer = y1 To y2 step sgn(dy)
circle (m * (y - y1) + x1,y), size, c, , , ,f
next
end if
end sub
const SCRW = 800
const SCRH = 600
screenres SCRW,SCRH,32
dim shared as integer mx,my,mb
dim as integer id 'current selected pivot
dim as single angle 'accumulating angle
dim as single mag 'magnification
mag = 1
type BONE
as single x1 'pivot point position
as single y1
as single x2 'rotated end point of bone
as single y2
as single a 'angle of joint
as single aMin 'limits of joint movement
as single aMax
as single s 'size
as ulong c
end type
'const TOT = 5
dim shared as BONE bones(0 to 11)
'dim shared as BONE bones2(0 to TOT-1)
bones(0).s = 50 'length
bones(1).s = 50
bones(2).s = 50
bones(3).s = 50
bones(4).s = 50
bones(5).s = 50 'foot
bones(0).a = 180 'starting angles must be between rotational limits
bones(1).a = -2
bones(2).a = -4
bones(3).a = -6
bones(4).a = -8
bones(5).a = -10
bones(0).c = rgb(255,0,0)
bones(1).c = rgb(0,255,0)
bones(2).c = rgb(0,0,255)
bones(3).c = rgb(255,0,255)
bones(4).c = rgb(200,0,50)
bones(5).c = rgb(50,0,200)
'==============================
bones(6).s = 50 'length
bones(7).s = 50
bones(8).s = 50
bones(9).s = 50
bones(10).s = 50
bones(11).s = 50 'foot
bones(6).a = 0 'starting angles must be between rotational limits
bones(7).a = 2
bones(8).a = 4
bones(9).a = 6
bones(10).a = 8
bones(11).a = 10
bones(6).c = rgb(255,0,0)
bones(7).c = rgb(0,255,0)
bones(8).c = rgb(0,0,255)
bones(9).c = rgb(255,0,255)
bones(10).c = rgb(200,0,50)
bones(11).c = rgb(50,0,200)
'=======================================
do
getMouse mx,my,,mb
if mb = 1 then 'see of on a pivot point
for i as integer = 0 to 11
if mx> bones(i).x1-5 and mx< bones(i).x1 +5 and _
my> bones(i).y1-5 and my< bones(i).y1 +5 then
id = i
end if
next i
end if
dim as integer x1,y1
screenlock
cls
angle = 0
x1 = SCRW\2 'starting point
y1 = SCRH\2
for i as integer = 0 to 11
if i = 6 then 'change start point
x1 = SCRW\2+10
y1 = SCRH\2
angle = 0
end if
bones(i).x1 = x1
bones(i).y1 = y1
angle = angle + bones(i).a
if angle < 0 then angle = angle + 360
if angle > 359 then angle = angle - 360
bones(i).x2 = bones(i).x1 + cos(angle*DtoR) * bones(i).s * mag
bones(i).y2 = bones(i).y1 + sin(angle*DtoR) * bones(i).s * mag
drawLine (bones(i).x1,bones(i).y1,bones(i).x2,bones(i).y2,3,bones(i).c)
circle (bones(i).x1,bones(i).y1),5,rgb(255,255,0) 'display pivot point
if id=i then
circle (bones(i).x1,bones(i).y1),5,rgb(255,255,0),,,,f 'selected pivot
end if
x1 = bones(i).x2
y1 = bones(i).y2
next i
locate 2,1
for i as integer = 0 to 11
print " bones(";str(i);").a =";bones(i).a
next i
print " MAG = ";mag
print " Select yellow pivot point with mouse button down"
print " Use keys A and D to rotate joint selected"
screenunlock
if multikey(&H1E) then 'key A
bones(id).a = bones(id).a + 1
if bones(id).a > 359 then bones(id).a = bones(id).a - 360
end if
if multikey(&H20) then 'key D
bones(id).a = bones(id).a - 1
if bones(id).a < 0 then bones(id).a = bones(id).a + 360
end if
sleep 2
loop until multikey(&H01)
Last edited by BasicCoder2 on Mar 17, 2018 2:52, edited 3 times in total.
Re: Sprite and tile collision demo
Works and looks good.BasicCoder2 wrote: Here I imagine two spider like legs.
Re: Sprite and tile collision demo
It depends on what you would want. You could use a particle emitter for hair now that Blender has hair and cloth physics with the cycles engine. Most 3d games keep expensive physics such as these to a minimum. In 3d games, whenever possible, rigging the mesh to bones is used instead.BasicCoder2 wrote: So in 3d graphics the strands hair or groups of strands of hair require finger-like rigging? Same with clothes? Something I didn't know or at least think about.
This sprite was rendered in blender with cloth physics.