Hello, everyone! For the past couple days I've been bored, so I decided to play around with programming (since I hadn't in a while). Cookie Clicker seemed easy enough to make, so I decided to try to port/clone it (not sure which to call it; a port or a clone?). I tried making it as accurate to the original as I possibly could. It's pretty simple for now. I plan on adding a saving/loading feature to save your data when you exit the program and to load it back up when you re-enter it later. So far I could only get the Cursors through the Time Machines to work properly in the shop. Here is a screenie to show what I've done so far:



(Idea and Sprites are not mine; they were created by Orteil)


Edit: Here is the link to the file in the archives: http://www.cemetech.net/programs/index.php?mode=file&id=1127
Wow that looks very nice Spenceboy98. I am always excited to see new development for the casio prizm. I have never heard of this game before but it appears all you do is click on the cookie. Or is there more to it?
Yup, thats it, Im not sure how it works but it would be nice if the cookie gets enlarged when you click it and shrinks to its normal size again just like the actual game
ProgrammerNerd wrote:
Wow that looks very nice Spenceboy98. I am always excited to see new development for the casio prizm. I have never heard of this game before but it appears all you do is click on the cookie. Or is there more to it?


You pretty much just click the cookie and gain cookies until you can purchase upgrades and such from the store. The upgrades give you a certain amount of cookies per second (CpS), so you don't have to click manually as much. Here is a link to the original game.

APotato wrote:
Yup, thats it, Im not sure how it works but it would be nice if the cookie gets enlarged when you click it and shrinks to its normal size again just like the actual game


I was planning on doing that with the cookie size, but the scale routine I have makes it look corrupted if it's over a certain size (the same scale routine I used for my Paint program). I'd rather not just use a smaller version of the sprite because the more sprites there are, the bigger the program is (and I'd rather it not be too big unless it has to be).
Try this instead. I am not sure how you are handling transparency so this code does not handle it.

Code:

void nearestNeighbor(unsigned w1,unsigned h1,unsigned w2,unsigned h2,uint16_t*in,uint16_t*out){
      unsigned x_ratio = ((w1<<16)/w2)+1;
      unsigned y_ratio = ((h1<<16)/h2)+1;
      unsigned x2,y2,i,j;
      for (i=0;i<h2;++i){
         for (j=0;j<w2;++j){
            x2 = ((j*x_ratio)>>16);
            y2 = ((i*y_ratio)>>16);
            *out++=in[(y2*w1)+x2];
         }
         out+=SCREEN_WIDTH-w2;   
      }
   }
}
That's pretty much the same as my first one (except for maybe a few differences). XD I did find one that works now, but thanks for the help anyways! Razz I might try yours later in my Paint program to see if it works better than my other one, though (if the version of Paint I have on this computer is the latest).
I thought by distortion you meant it had a bug. This algorithm just copies pixels to make it look large and skips pixels to make it smaller. The small amount of scaling that the game does when I played it should mean that pixelation should not be that bad.
I'm glad to see a new programming project for the Prizm ! Very Happy

That's not my favourite game or the funiest game ever, but I'm always excited when I can put a new game/programm on my calc ! Smile

Good luck, I keep it in sight.
This is what I mean:




I'm fairly certain that it's because the size of the output has to be larger than the size of the original, and in my Paint program, I don't have enough ram for that.
I have to say the graphics look nice, not something I've ever played, though. Not enough star ships and explosions :p
Yes you do need enough ram. Why not just draw directly to the VRAM? It could also be that there is a bug in the scaling function you made. Try mine.
I tried yours with my Paint program and it was even more corrupt than the first (I still think it's the ram issues, though).

tifreak8x wrote:
I have to say the graphics look nice, not something I've ever played, though. Not enough star ships and explosions :p


Thanks (not my graphics, though XD)! I understand if you haven't played. I think it's mostly a game for those who have no time to do anything better. Razz
Your doing something wrong. Did you post the source code?
I want to see what is causing this issue.
Here is what your scaling routine gives me in the cookie game:


Here is the code that I'm using for it:

Code:

//This is your routine, I just changed the name and the order of the arguments
void Scale1(color_t *out, color_t *in, unsigned w1, unsigned h1, unsigned w2, unsigned h2){
      unsigned x_ratio = ((w1<<16)/w2)+1;
      unsigned y_ratio = ((h1<<16)/h2)+1;
      unsigned x2,y2,i,j;
      for (i=0;i<h2;++i){
         for (j=0;j<w2;++j){
            x2 = ((j*x_ratio)>>16);
            y2 = ((i*y_ratio)>>16);
            *out++=in[(y2*w1)+x2];
         }
         out+=384-w2;   
      }
}

//the scaled array ("out" in your routine). It's the same size as the perfectCookie sprite
color_t scale[29524];


Scale1(scale, perfectCookie, 121, 122, ScaleW, ScaleH);
CopySpriteMasked(scale, ((ScaleW < 121) ? 29 : 25), ((ScaleH < 122) ? 83 : 79), ScaleW, ScaleH, COLOR_RED);
This gotta be the nicest looking Cookie Clicker clone of all calc models Very Happy
The problem is my code was assuming you were writing directly to vram. You created an array which is not needed. If you want to use the array method all you would have had to have done was remove the line that said

Code:

   out+=384-w2;

Also did the array take into account the maximum size of the image?
Try this code instead

Code:

void Scale1(color_t *out, color_t *in, unsigned w1, unsigned h1, unsigned w2, unsigned h2){ 
   unsigned x_ratio = ((w1<<16)/w2)+1; 
   unsigned y_ratio = ((h1<<16)/h2)+1; 
   unsigned x2,y2,i,j; 
   for (i=0;i<h2;++i){ 
      for (j=0;j<w2;++j){ 
         x2 = ((j*x_ratio)>>16); 
         y2 = ((i*y_ratio)>>16); 
         color_t p=in[(y2*w1)+x2];
         if(p!=COLOR_RED)           
            *out++=p; 
      }
   out+=384-w2;
   }
}
Scale1((color_t*)0xA8000000+((ScaleW < 121) ? 29 : 25)+(((ScaleH < 122) ? 83 : 79)*384), perfectCookie, 121, 122, ScaleW, ScaleH);

For this code you do not need CopySpriteMasked.
ProgrammerNerd wrote:
The problem is my code was assuming you were writing directly to vram. You created an array which is not needed. If you want to use the array method all you would have had to have done was remove the line that said

Code:

   out+=384-w2;

Also did the array take into account the maximum size of the image?
Try this code instead

Code:

void Scale1(color_t *out, color_t *in, unsigned w1, unsigned h1, unsigned w2, unsigned h2){ 
   unsigned x_ratio = ((w1<<16)/w2)+1; 
   unsigned y_ratio = ((h1<<16)/h2)+1; 
   unsigned x2,y2,i,j; 
   for (i=0;i<h2;++i){ 
      for (j=0;j<w2;++j){ 
         x2 = ((j*x_ratio)>>16); 
         y2 = ((i*y_ratio)>>16); 
         color_t p=in[(y2*w1)+x2];
         if(p!=COLOR_RED)           
            *out++=p; 
      }
   out+=384-w2;
   }
}
Scale1((color_t*)0xA8000000+((ScaleW < 121) ? 29 : 25)+(((ScaleH < 122) ? 83 : 79)*384), perfectCookie, 121, 122, ScaleW, ScaleH);

For this code you do not need CopySpriteMasked.


Oh, okay. I understand now. I just tried it in my Paint program and it works a lot better. I think I'll use this routine for Cookie Clicker now so it uses less ram. Razz


Quote:
This gotta be the nicest looking Cookie Clicker clone of all calc models Very Happy


Thanks! I tried making it as close as to the original graphics-wise. Razz
You used that for your paint program? If so did you read my code?

Code:

      color_t p=in[(y2*w1)+x2];
      if(p!=COLOR_RED)           
         *out++=p;

I put that there to so transparent parts of the cookie are not drawn.
This will is most likely not what you want for your paint program. If using this for paint program replace the above code with

Code:

      *out++=in[(y2*w1)+x2]
ProgrammerNerd wrote:
You used that for your paint program? If so did you read my code?

Code:

      color_t p=in[(y2*w1)+x2];
      if(p!=COLOR_RED)           
         *out++=p;

I put that there to so transparent parts of the cookie are not drawn.
This will is most likely not what you want for your paint program. If using this for paint program replace the above code with

Code:

      *out++=in[(y2*w1)+x2]


I read your code. I used the previous code you gave me earlier for the paint program, so it works just fine. Razz



I also just finished the saving and opening routine for Cookie Clicker, so now it saves your current progress and loads it back up when you re-enter. I might release a demo soon (if I feel like it's worthy for the public). Razz
Sounds like we may have a new prizm program. I am excited to see what comes out of this.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement