Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 01:42 22 May 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : PicoMite VGA Sprites

Author Message
g0730n
Newbie

Joined: 14/05/2025
Location: United States
Posts: 14
Posted: 06:51am 19 May 2025
Copy link to clipboard 
Print this post

Can someone give me a barebones explanation of creating a simple 8x8 sprite and displaying it on screen?

I have been looking at some of the games made in MMBasic as well as studying a manual but I am still confused. I feel like there is something that I am not understanding lol.

If there is already a guide to doing this any links would be appreciated, thanks!
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4904
Posted: 07:11am 19 May 2025
Copy link to clipboard 
Print this post

Hi g0730n,

You can create a sprite (up to 32x32) with the sprite editor:

Sprite Editor

You store this file to A:/ or B:/. I always add the suffix ".SPR" to distinguish it from other graphics files.

In your program you load the sprite into RAM with:

SPRITE LOAD "name_of_the_sprite.SPR",1


Now this is sprite number 1

You show sprite 1 on screen with:

SPRITE WRITE 1,x,y,0


That is it.

From here you can move the sprite, hide the sprite, etc... But alsways refer to the sprite number (1 in this case).
You can make things much more complex by using framebuffers, checking collisions, etc. But this is the essence.

Volhout

P.S. This version of flappy bird for VGA use sprites.
flappyVGA.zip
.
Edited 2025-05-19 17:17 by Volhout
PicomiteVGA PETSCII ROBOTS
 
g0730n
Newbie

Joined: 14/05/2025
Location: United States
Posts: 14
Posted: 07:59am 19 May 2025
Copy link to clipboard 
Print this post

  Volhout said  Hi g0730n,

You can create a sprite (up to 32x32) with the sprite editor:

Sprite Editor

You store this file to A:/ or B:/. I always add the suffix ".SPR" to distinguish it from other graphics files.

In your program you load the sprite into RAM with:

SPRITE LOAD "name_of_the_sprite.SPR",1


Now this is sprite number 1

You show sprite 1 on screen with:

SPRITE WRITE 1,x,y,0


That is it.

From here you can move the sprite, hide the sprite, etc... But alsways refer to the sprite number (1 in this case).
You can make things much more complex by using framebuffers, checking collisions, etc. But this is the essence.

Volhout

P.S. This version of flappy bird for VGA use sprites.
flappyVGA.zip
.


Thanks Volhout, that was straight to the point, EXACTLY what I was looking for! Going to load that sprite editor up and get started experimenting.
 
g0730n
Newbie

Joined: 14/05/2025
Location: United States
Posts: 14
Posted: 02:05pm 19 May 2025
Copy link to clipboard 
Print this post

It's all working great!

I decided to make a roguelike/rpg style game, which is actually a remake of a text based game I made on the Smart Response XE running Arduino Basic, but was limited to 4k program size and wasn't able to fit the last bit in there so shelved it then lost the code.





 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4904
Posted: 04:23pm 19 May 2025
Copy link to clipboard 
Print this post

You are fast....amazing.

I look forward to the game play.

Volhout
.
PicomiteVGA PETSCII ROBOTS
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 1196
Posted: 04:41pm 19 May 2025
Copy link to clipboard 
Print this post

Hi g0730n,
I've mad a Step-by-Step Guide some Times ago.
I think this will help you with the first steps. Instead of my SpriteEditor I now mainly use “Paint.net” to create the sprites and then convert them with the small Basic programs under MMBasic for Windows.
Example:



Cheers
Martin
Edited 2025-05-20 02:51 by Martin H.
'no comment
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2409
Posted: 05:17pm 19 May 2025
Copy link to clipboard 
Print this post

I had a go at sprites and abreviated the colours and used data with graph paper

option DEFAULT INTEGER
'OPTION EXPLICIT

dim dx(15),dy(15),spx(15),spy(15),sht,swid
dim ptr,hiscore,spw,spht,temp,frame,frame_count,spdata,sp1
hiscore=0

'colour shortcuts
const WH =RGB(255,  255,  255) 'WHITE
const YE =RGB(255,  255,    0) 'YELLOW
const LI =RGB(255,  128,  255) 'LILAC
const BR =RGB(255,  128,    0) 'BROWN
const FU =RGB(255,  64,   255) 'FUCHSIA
const RU =RGB(255,  64,     0) 'RUST
const MA =RGB(255,  0,    255) 'MAGENTA
const RE =RGB(255,  0,      0) 'RED
const CY =RGB(0,    255,  255) 'CYAN
const GR =RGB(0,    255,    0) 'GREEN
const CE =RGB(0,    128,  255) 'CERULEAN
const MI =RGB(0,    128,    0) 'MIDGREEN
const CO =RGB(0,    64,   255) 'COBALT
const MY =RGB(0,    64,     0) 'MYRTLE
const BL =RGB(0,    0,    255) 'BLUE
const Bk =RGB(0,    0,      0) 'BLACK
const Gy =RGB(128,  128,  128) 'GREY
const Lg =RGB(210,  210,  210) 'LITEGREY
const Og =RGB(255,  165,    0) 'ORANGE
const PK =RGB(255,  160,  171) 'PINK
const Gd =RGB(255,  215,    0) 'GOLD
const SA =RGB(250,  128,  114) 'SALMON
const BE =RGB(245,  245,  220) 'BEIGE

Dim array%(16*16+16*16+12*10+1*16) '16x16 sprite
restore sprite1
For temp=0 To 255:Read  array%(temp):Next temp
Sprite LOADARRAY 1, 16,16, array%()
'
restore sprite2
For temp=0 To 255:Read  array%(temp):Next temp
Sprite LOADARRAY 2, 16,16, array%()
'erase array%()
'
'Dim array%(119) '12x10 sprite
restore cannon
For temp=0 To 119:Read  array%(temp):Next temp
Sprite LOADARRAY #3, 12,10, array%()
'erase array%()
'
'Dim array%(15) '1x16 sprite
restore missile
For temp=0 To 15:Read  array%(temp):Next temp
Sprite LOADARRAY #4, 1,16, array%()
erase array%()
'


'
'cls
'restore sprite1:sht=15:swid=15
'udg1 'draws sprite1 on screen at 10,10
'sprite READ 1,10,10,16,16 'reads sprite1 from screen to blit buffer1
'
'restore sprite2
'udg1 'draws sprite2 on screen at 10,10
'sprite read 2,10,10,16,16 'reads sprite2 from screen to blit buffer2
'
'restore cannon:sht=9:swid=11
'udg1 'draws sprite1 on screen at 10,10
'sprite READ 3,10,10,12,10 'reads sprite1 from screen to blit buffer1
'
'restore missile:sht=15:swid=0
'udg1 'draws sprite1 on screen at 10,10
'sprite READ 4,10,10,1,16 'reads sprite1 from screen to blit buffer1
'
'




'
for temp=0 to 15 'set up start sprite positions and directions

 spx(temp)=(mm.hres /2)-32+int(rnd*64)
 spy(temp)=(mm.vres /2)-20+int(rnd*40)    
do :dx(temp)=int(rnd*5)-int(rnd*9):loop until dx(temp)<>0
do :dy(temp)=int(rnd*5)-int(rnd*9):loop until dy(temp)<>0

next temp
'
FRAMEBUFFER CREATE F

 FRAMEBUFFER WRITE f

do 'demo moving sprite
 
 cls RGB(black)
   for temp=0 to 15
'        if sprite_status(temp)=1 then 'is sprite active
           if spx(temp)> mm.hres-32 then 'check right edge
             dx(temp)= 0-dx(temp)
           elseif spx(temp)<16 then 'check left edge
             dx(temp)= 0-dx(temp)
           end if
           if spy(temp)>mm.vres-32 then 'check bottom edge
             dy(temp)= 0-dy(temp)
           elseif spy(temp)<16 then 'check top edge
             dy(temp)= 0-dy(temp)
           end if
     '
           spx(temp)=spx(temp)+dx(temp):spy(temp)=spy(temp)+dy(temp) 'get new position for draw
     '
               if frame=0 then'which sprite to draw
                 sprite WRITE 1,spx(temp),spy(temp) 'draw sprite1 at new position
               else
                 sprite WRITE 2,spx(temp),spy(temp) 'draw sprite2 at new position
               end if
   next temp
 
 FRAMEBUFFER COPY f,N
'
   frame_count=frame_count+1 'when to change sprite
   if frame_count=10 then
     frame=not frame
     frame_count=0
   end if
   pause 50
loop
'
sub udg1 'draws data for blit to copy
 for spht=0 to sht
   for spw=0 to swid
     read sp1
     pixel spw+10,spht+10,sp1
   next spw
 next spht
end sub
'
sprite1:
data wh,bl,bl,bl,bl,bk,bk,bk,bk,bk,bk,bl,bl,bl,bl,wh
data bk,bl,re,re,re,bl,bl,bk,bk,bl,bl,re,re,re,bl,bk
data bk,bk,bk,bl,re,wh,bl,bk,bk,bl,wh,re,bl,bk,bk,bk
data bk,bk,bk,bl,re,wh,bl,bk,bk,bl,wh,re,bl,bk,bk,bk
data bk,bk,bk,bk,bl,wh,bl,bk,bk,bl,wh,bl,bk,bk,bk,bk
data bk,bk,bk,bk,bk,bl,bl,bk,bk,bl,bl,bk,bk,bk,bk,bk
data bk,bk,bk,bk,bk,bk,bk,bk,bk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k,bk,bk,bk,bk,ye,bk,bk
data bk,bk,bk,ye,ye,bk,bk,bk,bk,bk,bk,ye,ye,bk,bk,bk
data bk,bk,bk,bk,ye,ye,bk,bk,bk,bk,ye,ye,bk,bk,bk,bk
data bk,bk,bk,bk,bk,ye,bk,bk,bk,bk,ye,bk,bk,bk,bk,bk
data bk,bk,bk,bk,bk,bk,ye,bk,bk,ye,bk,bk,bk,bk,bk,bk
cannon:
data bk,bk,bk,bk,bk,wh,wh,bk,bk,bk,bk,bk
data bk,bk,bk,bk,ye,cy,cy,ye,bk,bk,bk,bk
data bk,bk,bk,ye,cy,wh,wh,cy,ye,bk,bk,bk
data bk,bk,bk,ye,cy,cy,cy,cy,ye,bk,bk,bk
data bk,bk,ye,ye,cy,wh,wh,cy,ye,ye,bk,bk
data bk,bk,ye,cy,cy,cy,cy,cy,cy,ye,bk,bk
data bk,ye,bl,bl,bl,re,re,bl,bl,bl,ye,bk
data ye,ye,bl,bl,bl,re,re,bl,bl,bl,ye,ye
data bk,bk,ye,re,re,re,re,re,re,ye,bk,bk
data bk,bk,bk,ye,fu,fu,fu,fu,ye,bk,bk,bk
missile:
data wh,wh,re,re,ye,ye,wh,wh,wh,wh,ye,ye,re,re,wh,wh

 
g0730n
Newbie

Joined: 14/05/2025
Location: United States
Posts: 14
Posted: 12:52am 20 May 2025
Copy link to clipboard 
Print this post

Awesome thanks guys lots of great info!

i usually use paint.net while on windows, martin the link you provided is very helpful for going that route.

so far I have created 36 16x16 sprites in this game I am making, using your mmbasic sprite editor. I may make a few more but i have pretty much done all tiles, enemies, npc's and items that will be used in game. i dont plan on animating anything at this point.
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025