Author Topic: Enlarging sprites?  (Read 28165 times)

0 Members and 3 Guests are viewing this topic.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Enlarging sprites?
« Reply #30 on: June 07, 2010, 12:58:32 am »
Well I was a little bored and modified the last one. This is not very practical for stuff such as a tilemapper (I get 10 fps on one sprite) but for other stuff it can be useful maybe. In its current form it just animates through smallest zoom to the largest.

Code: [Select]
:.MAGX8
:ClrDraw
:ClrDrawr
:[3C42A59999A5423C]→Pic1
:[0000000000000000FFFFFFFFFFFFFFFF]→Pic2
:For(Z,10,80
:ClrDraw
:Pt-On(0,0,Pic1)
:For(C,0,8)
:C*Z/10→A
:For(D,0,8)
:D*Z/10→B
:Pt-Off(B+17,A,((pxl-Test(D,C)) and (C<8) and (D<8))*8+Pic2)
:End
:End
:DispGraph
:End

I am sure someone could poke this code with Quigibo's Axe of Optimization (sorry, stolen from Weregoose TI-BASIC stick of optimization... couldn't resist :P)
« Last Edit: June 07, 2010, 01:02:42 am by DJ Omnimaga »

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Enlarging sprites?
« Reply #31 on: June 07, 2010, 01:54:14 am »
 ;D Wow!  That's really cool!

On the topic of optimizations, why is there D<8 and C<8?  Can't the loop just go from 0 to 7 instead?  Other than that its pretty optimized.  But if you really want speed, you can actually read from the sprite data directly instead of using the getpixel command and then the sprite doesn't have to be drawn first either, but it is a little harder.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Enlarging sprites?
« Reply #32 on: June 07, 2010, 02:27:59 am »
Oh I did that since I was only drawing one single sprite. If I stop at 7, the last row and column will always be 8 pixels wide.

Could you explain how to draw from sprite data directly? Axe lacks a command to read individual bits from data, which I assume I would need to do that...
« Last Edit: June 07, 2010, 02:28:44 am by DJ Omnimaga »

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Enlarging sprites?
« Reply #33 on: June 07, 2010, 02:30:58 am »
You wouldn't use a bit command anyway since it would be a slower.
Code: [Select]
:.MAGX8
:[3C42A59999A5423C]→Pic1
:[0000000000000000FFFFFFFFFFFFFFFF]→Pic2
:For(Z,10,80
:ClrDraw
:For(C,0,8)
:C*Z/10→A
:{Pic1+C}→E
:For(D,0,8)
:D*Z/10→B
:Pt-Off(B+17,A,E^2 and (C<8) and (D<8)*8+Pic2)
:E/2→E
:End
:End
:DispGraph
:End
« Last Edit: June 07, 2010, 02:32:54 am by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Enlarging sprites?
« Reply #34 on: June 07, 2010, 03:51:30 am »
Oh ok I thought you meant a way to also draw each individual columns of pixels one by one too, not just rows. I guess just rows are not too hard then (well I don,t really understand the code that much but it seems to make a bit more sense than what I thought).

Sadly I did not notice that much of a speed increase, though. I used a stopwatch and the increase total was only like half a second. Still better than nothing I guess, though.

Size-wise, there's a huge difference, though. Even after deleting the two unnecessary ClrDraw commands at the top of my original code to drop my original program to 623 bytes, your optimizations made it drop to 457 bytes!

Thanks a lot

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Enlarging sprites?
« Reply #35 on: June 14, 2010, 01:34:02 am »
@Raylin
Any of this stuff help?
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline Raylin

  • Godslayer
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1392
  • Rating: +83/-25
  • I am a certifiable squirrel ninja.
    • View Profile
    • Ray M. Perry
Re: Enlarging sprites?
« Reply #36 on: June 14, 2010, 08:21:27 am »
Yes! It helps quite a bit.

I think that I underestimate the speed of which Axe can produce sprites. This would explain a lot of things.
Bug me about my book.

Sarah: TI-83 Plus Silver Edition [OS 1.19]
Cassie: TI-86 [OS 1.XX]
Elizabeth: TI-81 [OS 1.XX]
Jehuty: TI-83 Plus Silver Edition [OS 1.19]
Tesla: CASIO Prizm







Offline Galandros

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1140
  • Rating: +42/-10
    • View Profile
Re: Enlarging sprites?
« Reply #37 on: June 14, 2010, 09:54:54 am »
Looks really cool and fast. :o
I have to learn how to enlarge sprites like that. Enlarging by 2x is easy, though...
Hobbing in calculator projects.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Enlarging sprites?
« Reply #38 on: June 14, 2010, 01:07:15 pm »
Note: I would not recommend using zooming tilemappers, though. As you can notice in the screenshot, I get about 9 fps. After Quigibo optimization, I got 10. If I get 10 with only one sprite, imagine what it would be with 10+

Offline Raylin

  • Godslayer
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1392
  • Rating: +83/-25
  • I am a certifiable squirrel ninja.
    • View Profile
    • Ray M. Perry
Re: Enlarging sprites?
« Reply #39 on: June 14, 2010, 01:12:35 pm »
I only needed one sprite to be enlarged. :P
Bug me about my book.

Sarah: TI-83 Plus Silver Edition [OS 1.19]
Cassie: TI-86 [OS 1.XX]
Elizabeth: TI-81 [OS 1.XX]
Jehuty: TI-83 Plus Silver Edition [OS 1.19]
Tesla: CASIO Prizm







Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Enlarging sprites?
« Reply #40 on: June 14, 2010, 01:14:55 pm »
Aaah ok, should be good, then ^^

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Enlarging sprites?
« Reply #41 on: June 15, 2010, 02:34:14 pm »
Here's the code I just modified for 16x24 sprites:
Code: [Select]
:.MAGX8
:.I'm too lazy to put in my own 16x24 sprite
:[sprite data here]→Pic1
:[0000000000000000FFFFFFFFFFFFFFFF]→Pic2
:For(Z,10,80
:ClrDraw
:For(C,0,24)
:C*Z/10→A
:{C*2+Pic1}r→E
:For(D,0,16)
:D*Z/10→B
:Pt-Off(B+17,A,E^2 and (C<8) and (D<8)*8+Pic2)
:E/2→E
:End
:End
:DispGraph
:End

Should work, I hope.

Edit: typo
« Last Edit: June 15, 2010, 02:35:28 pm by calc84maniac »
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Enlarging sprites?
« Reply #42 on: June 15, 2010, 02:35:02 pm »
cool I'll try it when I get some time ^^

Offline Raylin

  • Godslayer
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1392
  • Rating: +83/-25
  • I am a certifiable squirrel ninja.
    • View Profile
    • Ray M. Perry
Re: Enlarging sprites?
« Reply #43 on: June 15, 2010, 02:39:09 pm »
I see that the community wants me to make this thing psuedo-3D.
Bug me about my book.

Sarah: TI-83 Plus Silver Edition [OS 1.19]
Cassie: TI-86 [OS 1.XX]
Elizabeth: TI-81 [OS 1.XX]
Jehuty: TI-83 Plus Silver Edition [OS 1.19]
Tesla: CASIO Prizm







Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Enlarging sprites?
« Reply #44 on: June 15, 2010, 02:42:49 pm »
XD

Try to not make something too large, though, if you do that. If you use pre-rendered map pics your game will get massive very fast and collision detection will quickly reach the 8 KB code limit x.x