Simple Game framework
-
- Posts: 3906
- Joined: Jan 01, 2009 7:03
- Location: Australia
Re: Simple Game framework
Although the routine label is called testCollision we are really just testing for the presence of an obstacle. When the player moves into a square next to a block they may be waiting for the right time to push the block to squish or trap the enemy we don't want blocks flying off at every contact. The block might be an object in another game to be picked up or have a button to press to open a door.
At the moment I am working on my sprite animator editor to refine animations of a walking sprites with 8 frames with 8 directions.
Pixel level art can be a tedious business and I am trying to think of ways of speeding it up.
.
At the moment I am working on my sprite animator editor to refine animations of a walking sprites with 8 frames with 8 directions.
Pixel level art can be a tedious business and I am trying to think of ways of speeding it up.
.
-
- Posts: 3906
- Joined: Jan 01, 2009 7:03
- Location: Australia
Re: Simple Game framework
Have updated the source code in the first post of the thread.
What I left out in the previous version was killing the bad guy when hit with a block. The addition is on line 207,
'===THIS SECTION TESTS FOR MOVING BLOCK HITTING ANOTHER SPRITE ==
Probably should add graphics to the moving block of a squashed bad guy if it is hit :) At this stage the bad guy just vanishes.
.
What I left out in the previous version was killing the bad guy when hit with a block. The addition is on line 207,
'===THIS SECTION TESTS FOR MOVING BLOCK HITTING ANOTHER SPRITE ==
Probably should add graphics to the moving block of a squashed bad guy if it is hit :) At this stage the bad guy just vanishes.
.
-
- Posts: 538
- Joined: Jul 15, 2005 4:13
Re: Simple Game framework
i really like the agent dude running around. You gotta make the green blobs look like burgulars...hehehhe
And have little sprites that look like household items that they are trying to steal. You gotta collect them all first!!!
And have little sprites that look like household items that they are trying to steal. You gotta collect them all first!!!
-
- Posts: 538
- Joined: Jul 15, 2005 4:13
Re: Simple Game framework
Or you could be the burglar and have a bunch of agents trys to catch you as to rob stores or banks...lol
-
- Posts: 3906
- Joined: Jan 01, 2009 7:03
- Location: Australia
Re: Simple Game framework
@thesanman112,
Yes you could do all sorts of games so have a go.
.
Yes you could do all sorts of games so have a go.
.
Re: Simple Game framework
been thinking alot about making a Sprite Animator/Pixel Drawing program as well. I think my idea has grown a bit complex as I am trying to incorporate some additional things like animation timings (on a per frame basis) as well as 'onion skinning' which is the term (I think) used to describe having the current working frame overlayed either the previous or the next frame to better see the transitions for smoother animations... I am afraid if I get too involved in the concept then I may never make it at all though... I do think such a FreeBasic program would be a boon to all of us amateur artists etc....BasicCoder2 wrote:At the moment I am working on my sprite animator editor to refine animations of a walking sprites with 8 frames with 8 directions.
Pixel level art can be a tedious business and I am trying to think of ways of speeding it up.
Re: Simple Game framework
I like the idea of a sprite editor.leopardpm wrote:been thinking alot about making a Sprite Animator/Pixel Drawing program as well. I think my idea has grown a bit complex as I am trying to incorporate some additional things like animation timings (on a per frame basis) as well as 'onion skinning' which is the term (I think) used to describe having the current working frame overlayed either the previous or the next frame to better see the transitions for smoother animations... I am afraid if I get too involved in the concept then I may never make it at all though... I do think such a FreeBasic program would be a boon to all of us amateur artists etc....
I made an attempt at a vector sprite animation tool a while back but didn't get far. The idea behind it was to reduce pixel level drawing monotony.
Re: Simple Game framework
BasicCoder2: What is your screen size again? I know you prefer it smaller, something like 1024 x 600... but forget the actual dimensions... I figure if I am going to make something 'useful' then it should at least work well with the one possible main user that I know!
Here is the basic layout I am considering:
The boxes across the top will show each animation (for instance: idle, walking, attacking, chopping wood, etc) - these will animate through all the frames of each animation, with the animation to be controlled (on/off) by a button selection. User can click on any animation and it will then show an enlarged version in the MAIN area - the 'grid' of this area will show a sprite frame of maximum 128 x 128 at each grid cell being sized to a max of 4 pixels. This means that the total top to bottom screen area consumed is: 128 pix for the top row of sprites + main area of 128*4= 512pix.... 640 pix total. This is why I am asking for your max screen dimensions....
Here is the basic layout I am considering:
The boxes across the top will show each animation (for instance: idle, walking, attacking, chopping wood, etc) - these will animate through all the frames of each animation, with the animation to be controlled (on/off) by a button selection. User can click on any animation and it will then show an enlarged version in the MAIN area - the 'grid' of this area will show a sprite frame of maximum 128 x 128 at each grid cell being sized to a max of 4 pixels. This means that the total top to bottom screen area consumed is: 128 pix for the top row of sprites + main area of 128*4= 512pix.... 640 pix total. This is why I am asking for your max screen dimensions....
-
- Posts: 3906
- Joined: Jan 01, 2009 7:03
- Location: Australia
Re: Simple Game framework
@Leopardpm,
Probably maximum window would be 1280x600 to fit ok.
The reason I haven't finished any sprite editor is because I found they did not turn me into a better artist or animator.
A tool is only as good as the user.
Drawing a nice version of all those isometric frames would take forever.
A 3D creation tool like Blender is probably a better path for someone with limited artistic abilities.
Having costumed actors carry out the actions would be the easiest approach for the isometric characters
The efforts below I hadn't posted as they were unfinished. They were just skeletons of ideas to be expanded.
This is an older one 2015. Animation does not require the character be painted until after the outlines are done.
And this was a more recent one which has numbers to fit the sprite block that Boromir has been using without the standing still frames.
The idea was you could edit the whole block.
There is no sprite block bitmap here so I just filled it with rectangles.
There is also no palette bitmap here so I just filled it with random colors.
All the routines to make it into a proper editor exist elsewhere in various paint programs I have done in the past.
These were very rudimentary experiments into how I might go about it and as I mention above I realized they were not going to work unless I magically became better at drawing animations.
Probably maximum window would be 1280x600 to fit ok.
The reason I haven't finished any sprite editor is because I found they did not turn me into a better artist or animator.
A tool is only as good as the user.
Drawing a nice version of all those isometric frames would take forever.
A 3D creation tool like Blender is probably a better path for someone with limited artistic abilities.
Having costumed actors carry out the actions would be the easiest approach for the isometric characters
The efforts below I hadn't posted as they were unfinished. They were just skeletons of ideas to be expanded.
This is an older one 2015. Animation does not require the character be painted until after the outlines are done.
Code: Select all
screenres 640,480,32
color rgb(0,0,0),rgb(255,255,255) 'white paper, black ink
cls 'implements color command
const nFrames = 8 'number of frames
const wSprite = 32 'width of sprite
const hSprite = 32 'height of sprite
const SIZE = 12 'size of grid pixel.
const POSX = 220 'top/left position of grid on screen
const POSY = 64
dim shared as integer mx,my,ox,oy,mb 'mouse variables
dim shared as uinteger selectedColor 'current color selected
dim shared as any ptr sprite(nFrames) 'current sprite image
dim shared as integer currentFrame 'current image being edited
selectedColor = rgb(0,0,0)
for i as integer = 0 to nFrames-1
sprite(i) = imageCreate(wSprite,hSprite,rgb(255,255,255)) 'frames
next i
sub upDate(fade as integer)
dim as uinteger r,g,b,p
'screenlock
'copy pixel values from sprite to grid display
line (POSX-2,POSY-2)-(POSX+SIZE*wSprite+2,POSY+SIZE*hSprite+2),rgb(10,10,10),b
for j as integer = 0 to hSprite-1
for i as integer = 0 to wSprite-1
p = point(i,j,sprite(currentFrame))
r = p shr 16 and 255
g = p shr 8 and 255
b = p and 255
line (i*SIZE+POSX+1,j*SIZE+POSY+1)-(i*SIZE+SIZE+POSX-1,j*SIZE+SIZE+POSY-1),rgb(r,g,b),bf
line (i*SIZE+POSX,j*SIZE+POSY)-(i*SIZE+SIZE+POSX,j*SIZE+SIZE+POSY),rgb(100,100,255),b
if currentFrame<>0 and fade = 1 then 'show previous drawing
if point(i,j,sprite(currentFrame))=rgb(255,255,255) then
p = point(i,j,sprite(currentFrame-1))
if p<>rgb(255,255,255) then
r = p shr 16 and 255
g = p shr 8 and 255
b = p and 255
r = r*4 and &HFFFFFF
g = g*4 and &HFFFFFF
b = b*4 and &HFFFFFF
line (i*SIZE+POSX+1,j*SIZE+POSY+1)-(i*SIZE+SIZE+POSX-1,j*SIZE+SIZE+POSY-1),rgb(127,127,127),bf
end if
end if
end if
next i
next j
locate 38,2
print "[.] move forward one frame"
locate 40,2
print "[,] move back one frame"
locate 42,2
print "[S] to save sprites"
locate 44,2
print "[L] to load sprites"
locate 46,2
print "[C] to clear sprites"
locate 48,2
print "[ESC] TO END PROGRAM"
locate 50,2
print "[A] TO ANIMATE"
'display sprite
line (4,4)-(37,37),rgb(10,10,10),b
line (2,2)-(39,39),rgb(10,10,10),b
put (5,5),sprite(currentFrame),pset
locate 10,3
print "FRAME =";currentFrame;" "
'screenunlock
end sub
sub SaveSprites()
for i as integer = 0 to nFrames-1
bsave "C:/FreeBasic/bitmaps/tSprite"+str(i)+".bmp",sprite(i)
next i
end sub
sub LoadSprites()
for i as integer = 0 to nFrames-1
bload "C:/FreeBasic/bitmaps/tSprite"+str(i)+".bmp",sprite(i)
next i
upDate(1)
end sub
sub animate(delay as double)
dim as double now1
currentFrame = 0
now1 = timer
update(0)
do
if timer > now1 + delay then
now1 = timer
update(0)
currentFrame = currentFrame + 1
if currentFrame >= nFrames-1 then
currentFrame = 0
end if
end if
sleep 2
loop until multikey(&H01)
end sub
'MAIN PROGRAM
upDate(1)
getmouse mx,my,,mb
ox = mx
oy = my
dim as integer i,j
dim as string key
do
key = inkey
if ucase(key) = "S" then
SaveSprites()
end if
if ucase(key) = "L" then
LoadSprites()
end if
if ucase(key) = "C" then
for i as integer = 0 to nFrames-1
line sprite(i),(0,0)-(wSprite,hSprite),rgb(255,255,255),bf
next i
upDate(1)
end if
if ucase(key) = "A" then
animate(0.05)
end if
if key = "," then
currentFrame = currentFrame-1
if currentFrame < 0 then
currentFrame = nFrames-1
end if
upDate(1)
end if
if key = "." then
currentFrame = currentFrame+1
if currentFrame > (nFrames-1) then
currentFrame = 0
end if
upDate(1)
end if
getmouse mx,my,,mb
'over drawing area?
if mx>POSX and mx<POSX+wSprite*SIZE+SIZE-1 and my>POSY and my<POSY+hSprite*SIZE+SIZE-1 then
if mb = 1 then
pset sprite(currentFrame),((mx-POSX)\SIZE,(my-POSY)\SIZE),selectedColor
update(1)
while mb=1
getmouse mx,my,,mb
if ox<>mx or oy<>my then
pset sprite(currentFrame),((mx-POSX)\SIZE,(my-POSY)\SIZE),selectedColor
upDate(1) 'copy sprite pixel values to grid, display result with fade
ox = mx
oy = my
end if
sleep 2
wend
end if
end if
sleep 2
loop until multikey(&H01)
The idea was you could edit the whole block.
There is no sprite block bitmap here so I just filled it with rectangles.
There is also no palette bitmap here so I just filled it with random colors.
All the routines to make it into a proper editor exist elsewhere in various paint programs I have done in the past.
These were very rudimentary experiments into how I might go about it and as I mention above I realized they were not going to work unless I magically became better at drawing animations.
Code: Select all
screenres 768,480,32
color rgb(0,0,0),rgb(255,255,255):cls 'black ink, white paper
dim shared as integer mx,my,mb
const TILEW = 25
const TILEH = 45
dim shared as any ptr spriteBlock
spriteBlock = imagecreate(8*TILEW,8*TILEH,rgb(255,0,255))
for j as integer = 0 to 7 'directions
for i as integer = 0 to 7 'frames
line spriteBlock,(i*TILEW,j*TILEH)-(i*TILEW+TILEW-1,j*TILEH+TILEH-1),rgb(0,0,0),b
next i
next j
'bload "animBlock.bmp",spriteBlock
dim shared as any ptr palette1
palette1 = imagecreate(512,16)
for i as integer = 0 to 31
line palette1,(i*16,0)-(i*16+15,15),rgb(int(rnd(1)*256),int(rnd(1)*256),int(rnd(1)*256)),bf
next i
'bload "palette1.bmp",palette1
dim shared as integer frame, direction
dim shared as integer selectedColor
selectedColor = rgb(0,0,0)
sub drawImage()
screenlock
cls
for j as integer = 0 to TILEH-1
for i as integer = 0 to TILEW-1
line (i*8,j*8)-(i*8+7,j*8+7),point(frame*TILEW+i,direction*TILEH+j,spriteBlock),bf
next i
next j
locate 50,1
print " FRAME =";frame;" DIRECTION =";direction
print
print " CLICK RIGHT MOUSE BUTTON TO SELECT A COLOR"
print " THIS CAN BE ANY COLOR WITHIN THIS WINDOW"
print " USE ARROW KEYS TO SELECT AN IMAGE IN BLOCK"
put (400,0),spriteBlock,trans
line (frame*TILEW+400,direction*TILEH)-(frame*TILEW+TILEW-1+400,direction*TILEH+TILEH-1),rgb(255,0,0),b
put (320,240),spriteBlock,(frame*TILEW,direction*TILEH)-(frame*TILEW+TILEW-1,direction*TILEH+TILEH-1),trans
'show palette
put (0,460),palette1,trans
line (380,390)-(380+40,390+40),selectedColor,bf
line (380,390)-(380+40,390+40),rgb(0,0,0),b
screenunlock
end sub
dim as double time1
dim as integer x,y
time1 = timer
drawImage()
do
getmouse mx,my,,mb
if mx<384 and my<384 and mb=1 then 'down over drawing area
mx = mx\8
my = my\8
pset spriteBlock,(mx+(frame*TILEW),my+(direction*TILEH)),selectedColor
drawImage()
end if
if mb = 2 then
selectedColor = point(mx,my)
end if
if timer - time1 > 0.1 then
time1 = timer
If MultiKey(&H4B) Then frame = frame - 1
If MultiKey(&H4D) Then frame = frame + 1
If MultiKey(&H48) Then direction = direction - 1
If MultiKey(&H50) Then direction = direction + 1
if frame < 0 then frame = 7
if frame > 7 then frame = 0
if direction < 0 then direction = 7
if direction > 7 then direction = 0
drawImage()
end if
sleep 2
loop until multikey(&H01)
bsave "test.bmp",spriteBlock
imagedestroy spriteBlock
imagedestroy palette1
Re: Simple Game framework
This all is true, and points me straight back to why I was creating that IsoVox idea/routines: using voxels you get the added benefit of 3D info which means all the rotation frames could be automatically generated instead of by hand, yet still get the precise 'handdrawn pixelart' quality of regular pixel sprites, and also then has the possibility of incorporating a bone/joint rigging system on down the line to make the creation of the animations themselves much simpler much like how Blender would do it in full 3D. The advantage of using simple voxel models over full 3D is that they are much easier for a novice to make, almost like making a straight 2D sprite drawing yet having the 3rd dimension added. The real issue with voxel models is that, just like 2D pixelart, they are 'set' at a given resolution and get pixelated when enlarged, unlike true 3D models...BasicCoder2 wrote:The reason I haven't finished any sprite editor is because I found they did not turn me into a better artist or animator.
A tool is only as good as the user.
Drawing a nice version of all those isometric frames would take forever.
A 3D creation tool like Blender is probably a better path for someone with limited artistic abilities.
I will take a look at your code, hopefully later today - thanks for your screen size, I think that will be large enough to show enough useful information for manipulating animations easily. I will run the small sized animation frames vertically alongside of the enlarged, current drawing frame, instead of across the top to accomodate your limited height (600 vs 640), that should work well and perhaps even be easier for the user to understand.
Re: Simple Game framework
I tried your demo in the first post, but it was not easy to get it running. The first code part created 'agent.bmp', but that was not needed. What was needed is 'greenBlob1.bmp" and 'redPenguin1.bmp'. I found the code for that in follow-up posts.
But when I run it, there are 2 issues:
- "Aborting due to runtime error 6 (out of bounds array access) at line 149 of demo.bas::TILECOLLISION()" when running with -exx
- The animation speed depends on the sleep time (2 ms). Not all systems will do 2 ms by default.
But when I run it, there are 2 issues:
- "Aborting due to runtime error 6 (out of bounds array access) at line 149 of demo.bas::TILECOLLISION()" when running with -exx
- The animation speed depends on the sleep time (2 ms). Not all systems will do 2 ms by default.
Re: Simple Game framework
Hi
I don't know how i overview this very good example of simple bitmap editor .
@basicCoder2
is there a simple way to connect this 2 programs into one
which should be just bitmap editor in which we can draw small bitmap for
buttons or for bitmap static control ..so nothing special
i mean how to add color picker from second program to first program and draw bitmap?
I am not very good in that gfx graphic ,by the way is gfx just a wrapper for GDI on Windows?
I don't know how i overview this very good example of simple bitmap editor .
@basicCoder2
is there a simple way to connect this 2 programs into one
which should be just bitmap editor in which we can draw small bitmap for
buttons or for bitmap static control ..so nothing special
i mean how to add color picker from second program to first program and draw bitmap?
I am not very good in that gfx graphic ,by the way is gfx just a wrapper for GDI on Windows?
Re: Simple Game framework
I fogured that i need to copy this block to first progie:
Code: Select all
'draw palette 1
dim shared as any ptr palette1
palette1 = imagecreate(512,16)
for i as integer = 0 to 31
line palette1,(i*16,0)-(i*16+15,15),rgb(int(rnd(1)*256),int(rnd(1)*256),int(rnd(1)*256)),bf
next i
Re: Simple Game framework
so far i get this ...
so ..how select color to draw pixel...
http://aurelcode.info8-hosting.info/Upl ... php?aid=21
http://aurelcode.info8-hosting.info/Upl ... php?aid=21
so ..how select color to draw pixel...
http://aurelcode.info8-hosting.info/Upl ... php?aid=21
http://aurelcode.info8-hosting.info/Upl ... php?aid=21
Re: Simple Game framework
Ok
i figured where to put getmouse to pick color
i figured where to put getmouse to pick color
Code: Select all
screenres 640,480,32
color rgb(0,0,0),rgb(255,255,255) 'white paper, black ink
cls 'implements color command
const nFrames = 8 'number of frames
const wSprite = 32 'width of sprite
const hSprite = 32 'height of sprite
const SIZE = 12 'size of grid pixel.
const POSX = 220 'top/left position of grid on screen
const POSY = 64
dim shared as integer mx,my,ox,oy,mb 'mouse variables
dim shared as uinteger selectedColor 'current color selected
dim shared as any ptr sprite(nFrames) 'current sprite image
dim shared as integer currentFrame 'current image being edited
selectedColor = rgb(0,0,0)
'mb=2
for i as integer = 0 to nFrames-1
sprite(i) = imageCreate(wSprite,hSprite,rgb(255,255,255)) 'frames
next i
'draw palette 1
dim shared as any ptr palette1
palette1 = imagecreate(512,16)
for i as integer = 0 to 31
line palette1,(i*16,0)-(i*16+15,15),rgb(int(rnd(1)*256),int(rnd(1)*256),int(rnd(1)*256)),bf
next i
'show palette
put (0,460),palette1,trans
sub upDate(fade as integer)
dim as uinteger r,g,b,p
'screenlock
'copy pixel values from sprite to grid display
line (POSX-2,POSY-2)-(POSX+SIZE*wSprite+2,POSY+SIZE*hSprite+2),rgb(10,10,10),b
for j as integer = 0 to hSprite-1
for i as integer = 0 to wSprite-1
p = point(i,j,sprite(currentFrame))
r = p shr 16 and 255
g = p shr 8 and 255
b = p and 255
line (i*SIZE+POSX+1,j*SIZE+POSY+1)-(i*SIZE+SIZE+POSX-1,j*SIZE+SIZE+POSY-1),rgb(r,g,b),bf
line (i*SIZE+POSX,j*SIZE+POSY)-(i*SIZE+SIZE+POSX,j*SIZE+SIZE+POSY),rgb(100,100,255),b
if currentFrame<>0 and fade = 1 then 'show previous drawing
if point(i,j,sprite(currentFrame))=rgb(255,255,255) then
p = point(i,j,sprite(currentFrame-1))
if p<>rgb(255,255,255) then
r = p shr 16 and 255
g = p shr 8 and 255
b = p and 255
r = r*4 and &HFFFFFF
g = g*4 and &HFFFFFF
b = b*4 and &HFFFFFF
line (i*SIZE+POSX+1,j*SIZE+POSY+1)-(i*SIZE+SIZE+POSX-1,j*SIZE+SIZE+POSY-1),rgb(127,127,127),bf
end if
end if
end if
next i
next j
locate 38,2
print "[.] move forward one frame"
locate 40,2
print "[,] move back one frame"
locate 42,2
print "[S] to save sprites"
locate 44,2
print "[L] to load sprites"
locate 46,2
print "[C] to clear sprites"
locate 48,2
print "[ESC] TO END PROGRAM"
'locate 50,2
'print "[A] TO ANIMATE"
'display sprite
line (4,4)-(37,37),rgb(10,10,10),b
line (2,2)-(39,39),rgb(10,10,10),b
put (5,5),sprite(currentFrame),pset
locate 10,3
print "FRAME =";currentFrame;" "
'screenunlock
end sub
sub SaveSprites()
for i as integer = 0 to nFrames-1
bsave "C:/FreeBasic/bitmaps/tSprite"+str(i)+".bmp",sprite(i)
next i
end sub
sub LoadSprites()
for i as integer = 0 to nFrames-1
bload "C:/FreeBasic/bitmaps/tSprite"+str(i)+".bmp",sprite(i)
next i
upDate(1)
end sub
sub animate(delay as double)
dim as double now1
currentFrame = 0
now1 = timer
update(0)
do
if timer > now1 + delay then
now1 = timer
update(0)
currentFrame = currentFrame + 1
if currentFrame >= nFrames-1 then
currentFrame = 0
end if
end if
sleep 2
loop until multikey(&H01)
end sub
'MAIN PROGRAM
upDate(1)
getmouse mx,my,,mb
ox = mx
oy = my
'if mb = 2 then
' selectedColor = point(mx,my)
'end if
dim as integer i,j
dim as string key
do
key = inkey
if ucase(key) = "S" then
SaveSprites()
end if
if ucase(key) = "L" then
LoadSprites()
end if
if ucase(key) = "C" then
for i as integer = 0 to nFrames-1
line sprite(i),(0,0)-(wSprite,hSprite),rgb(255,255,255),bf
next i
upDate(1)
end if
if ucase(key) = "A" then
animate(0.05)
end if
if key = "," then
currentFrame = currentFrame-1
if currentFrame < 0 then
currentFrame = nFrames-1
end if
upDate(1)
end if
if key = "." then
currentFrame = currentFrame+1
if currentFrame > (nFrames-1) then
currentFrame = 0
end if
upDate(1)
end if
getmouse mx,my,,mb
'select color right click -----------------------
if mb = 2 then
selectedColor = point(mx,my)
end if
'------------------------------------------------
'over drawing area?
if mx>POSX and mx<POSX+wSprite*SIZE+SIZE-1 and my>POSY and my<POSY+hSprite*SIZE+SIZE-1 then
if mb = 1 then
pset sprite(currentFrame),((mx-POSX)\SIZE,(my-POSY)\SIZE),selectedColor
update(1)
while mb=1
getmouse mx,my,,mb
if ox<>mx or oy<>my then
pset sprite(currentFrame),((mx-POSX)\SIZE,(my-POSY)\SIZE),selectedColor
upDate(1) 'copy sprite pixel values to grid, display result with fade
ox = mx
oy = my
end if
sleep 2
wend
end if
end if
sleep 2
loop until multikey(&H01)