Author Topic: 16x16 sprite drawing routine request  (Read 4639 times)

0 Members and 1 Guest are viewing this topic.

souvik1997

  • Guest
16x16 sprite drawing routine request
« on: February 17, 2011, 10:35:13 pm »
Could someone please write a routine to draw 16x16 sprites? It should accept arguments like sub(SPR,XCoord,YCoord,Pointer).

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: 16x16 sprite drawing routine request
« Reply #1 on: February 17, 2011, 10:46:03 pm »
The easiest thing to do is just to store the 16x16 sprites as 4 individual 8x8 sprites, as Axe has no built-in 16x16 sprite drawing capabilities. You would then store the 4 individual sprites in memory with the top left corner first, then the top right corner, then the bottom left corner, and finally the bottom right corner. You could then draw the whole sprite with something like the following:

Code: [Select]
Lbl SPR
  Pt-On(r₁,r₂,r₃)
  Pt-On(r₁+8,r₂,r₃+8)
  Pt-On(r₁,r₂+8→r₂,r₃+16)
  Pt-On(r₁+8,r₂,r₃+24)
Return
« Last Edit: February 17, 2011, 10:46:26 pm by Runer112 »

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: 16x16 sprite drawing routine request
« Reply #2 on: February 26, 2011, 08:51:01 am »
Just use Bitmap(. Doesn't work in apps, though.
Syntaxis:
Code: [Select]
[heightinhex,widthinhex,hexcode->pic1
bitmap(xpos,ypos,pic1
So for a 16x16 sprite:
Code: [Select]
[1010hexcode]->pic1
bitmap(0,0,pic1
If you want to draw an 8x8 sprite too, put fix9 at the start and fix 8 at the end of your program
NOTE: you cant draw bitmap('s offscreen. if you do, you get a BSOD. (just pull a battery, but you know this, I think ;D)

I have an sprite editor that gives the hex, i'll upload it.
I lost...
« Last Edit: February 26, 2011, 08:51:53 am by aeTIos »
I'm not a nerd but I pretend:

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: 16x16 sprite drawing routine request
« Reply #3 on: February 26, 2011, 02:31:06 pm »
I would recomend staying away from bitmaps for 16x16 personally, since the routine is an OS routine, its incredibly slow.  Using 4 Pt-On commands like runner suggested would be a lot faster.  Bitmaps would be easier however.  So whatever your needs are, speed or ease of use, you can choose :)

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: 16x16 sprite drawing routine request
« Reply #4 on: February 26, 2011, 03:06:26 pm »
Yeah, that's what I did yesterday, I stored my 16x16 sprite as 4 8x8 sprites and used 4 Pt-On commands.

Code: [Select]
[hexcode]->Pic1A
[hexcode]->Pic1B
[hexcode]->Pic1C
[hexcode]->Pic1D
Pt-On(A,B,Pic1A)
Pt-On(A+8,B,Pic1B)
Pt-On(A,B+8,Pic1C)
Pt-On(A+8,B+8,Pic1D)

Then I would convert this code to make use of routines and I would get something like Runer112's code.
« Last Edit: February 26, 2011, 03:09:12 pm by juju2143 »

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.