Author Topic: [PRIZM] Cookie Clicker  (Read 15690 times)

0 Members and 1 Guest are viewing this topic.

Offline bb010g

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 428
  • Rating: +22/-1
  • I do stuff
    • View Profile
    • elsewhere on the net
Re: [PRIZM] Cookie Clicker
« Reply #15 on: July 13, 2014, 01:14:43 am »
I'm making it so that they appear above the F buttons, so that you just have to press the one that it's above to click it.
Great idea. :)
(PS: Change your sig HTML to BBCode.)
Arch Linux user
Haskell newbie | Warming up to Lua | Being dragged into C++
Calculators: HP 50g, HP 35s, Casio Prizm, TI-Nspire CX CAS, HP 28s, HP Prime, Mathematica 9 (if that counts)
π: 3.14...; l: 108; i: 105; e: 101; l+i+e: 314
THE CAKE IS A LIE IS A PIE

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: [PRIZM] Cookie Clicker
« Reply #16 on: July 13, 2014, 01:20:38 am »
Is the purple glitch due to the same problem you had with your (canceled?) Mode 7 engine? I like the custom fonts by the way :D

Offline Spenceboy98

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 547
  • Rating: +59/-2
    • View Profile
Re: [PRIZM] Cookie Clicker
« Reply #17 on: July 13, 2014, 09:24:08 pm »
Is the purple glitch due to the same problem you had with your (canceled?) Mode 7 engine? I like the custom fonts by the way :D

Thanks. :P I didn't use the CopySpriteMaskedAlpha routine in the Mode 7 engine, so it's probably not the same problem. :P For now, until I can get a working CopySpriteMaskedAlpha routine, the Golden Cookies won't fade in/out, they'll just appear.
I like milk.

Offline Spenceboy98

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 547
  • Rating: +59/-2
    • View Profile
Re: [PRIZM] Cookie Clicker
« Reply #18 on: July 15, 2014, 12:53:15 pm »

*BUMP*


Got golden cookies working (I had to fix my own alpha sprite routine).



(probably not actual speed. The values are messed up because of the screen receiver; not sure why)


They should appear every 5 to 10 minutes (I might make it shorter if requested enough).


Also the file size is smaller now because I changed the font images from 16-bit to 1-bit using SourceCoder. New version is attached. :P
I like milk.

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: [PRIZM] Cookie Clicker
« Reply #19 on: July 15, 2014, 05:39:21 pm »
One of the very few calc games to support translucent sprites? O.O

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: [PRIZM] Cookie Clicker
« Reply #20 on: July 16, 2014, 11:56:20 am »
Whoa nice job on making the sprites translucent indeed. O.O

Offline Princetonlion.tibd

  • Members
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 790
  • Rating: +3/-4
    • View Profile
Re: [PRIZM] Cookie Clicker
« Reply #21 on: July 16, 2014, 08:14:33 pm »
That looks awesome!

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: [PRIZM] Cookie Clicker
« Reply #22 on: July 19, 2014, 09:47:12 am »
By the way I finally tried this on calc (then left it run overnight) and it works pretty well. My only gripe about it is that key detection is not very responsive so if I try to mash the cookie key or move cursor down it sometimes doesn't do anything. Could this be due to low frame rate or something?

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: [PRIZM] Cookie Clicker
« Reply #23 on: July 22, 2014, 06:46:57 am »
Is this written in C? If so imma try porting it to Nspire :D
Edit: Aww, is this closed source? I can't find the source code. :(
« Last Edit: July 22, 2014, 06:49:02 am by aeTIos »
I'm not a nerd but I pretend:

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: [PRIZM] Cookie Clicker
« Reply #24 on: July 24, 2014, 01:47:20 am »
That said, considering the nature of this game, I doubt it would be super incredibly hard to port from scratch :P (except maybe the translucent cookies)

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: [PRIZM] Cookie Clicker
« Reply #25 on: July 27, 2014, 01:58:10 pm »
Translucent cookies are relatively simple :
Code: [Select]
In : color, alpha (between 0 and 1)
Out : colorOnScreen * (1 - alpha) + color * alpha
Apply that on every pixel of the sprite and you're done.

Offline ProgrammerNerd

  • LV3 Member (Next: 100)
  • ***
  • Posts: 50
  • Rating: +9/-2
    • View Profile
Re: [PRIZM] Cookie Clicker
« Reply #26 on: August 02, 2014, 04:33:38 pm »
That code you propose is very slow. Here is a faster way. I originally posted this at cemetech's useful function topic for the prizm but this code will work for any thing that uses rgb565 data. To port it change:
   unsigned short*v=(unsigned short*)0xA8000000; to wherever the framebuffer is.
Code: [Select]
/*Note it is up to the caller to ensure that alpha is in range of 1-31
 * For a value of 32 or greater just don't draw the image
 * For a value of 0 use a plain mask function that does not take into account alpha
 * Also make sure width is a multiple of two*/
void CopySpriteMaskedAlpha(unsigned *data,unsigned x,unsigned y,unsigned width,unsigned height,unsigned maskcolor,unsigned alpha){
unsigned short*v=(unsigned short*)0xA8000000;
unsigned* VRAM,w,alphai;
width/=2;
v += 384*y + x;
VRAM=v;
alphai=32-alpha;
maskcolor|=maskcolor<<16;/*Note I have decided to do a minor tradeoff for speed. Make sure your alpha pixels are multiple of two*/
while(height--){
w=width;
while(w--){
unsigned color1=*data++;
if(color1 != maskcolor){
/*Note this is based on the source code of Fblend's function fblend_rect_trans_16*/
unsigned rbg_source, grb_source,temp1;
/* Split up components to allow us to do operations on all of them at the same time */
rbg_source = *VRAM & 0xF81F07E0,
grb_source = *VRAM & 0x07E0F81F;

/* Multiply the source by the factor */
rbg_source = ((rbg_source >> 5) * alpha) & 0xF81F07E0;
grb_source = ((grb_source * alpha) >> 5) & 0x07E0F81F;

/* Split up RGB -> R-B and G */
temp1 = color1 & 0x7E0F81F;
color1 &= 0xF81F07E0;

/* Multiply the source by the factor */
color1 = ((((color1 >> 5) * alphai) & 0xF81F07E0) + rbg_source) & 0xF81F07E0;
temp1  = ((((temp1 * alphai) >> 5)  & 0x07E0F81F) + grb_source) & 0x07E0F81F;

color1 |= temp1;
*VRAM++=color1;
}else
++VRAM;
}
VRAM += (384/2)-width;
}
}
This code will actually handle a range of 0-32. Even though this function is fast it is faster to not draw the image (value of 32). Or just draw the image using mask function that does not worry about alpha (value of 0).
It admit to getting part of this code off from Fblend an open source project as you can see in the comment I put in the code. One good thing about the code is that it does two pixels at a time. However I decided to remove the checks for non multiples of two to further increase speed given the fact that you can just fix your image if needed. Also make sure that the alpha pixels are multiples of two. Also I found an interesting article talking about a few rgb565 tricks you may want to check out http://www.cprogramdevelop.com/4562354/