source: abuse/trunk/src/smoosh.cpp

Last change on this file was 555, checked in by Sam Hocevar, 9 years ago

ps3: make everything compile on the PS3. Of course, nothing links yet
because so much support is missing.

File size: 1.7 KB
RevLine 
[56]1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
[494]4 *  Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net>
[56]5 *
6 *  This software was released into the Public Domain. As with most public
[555]7 *  domain software, no warranty is made or implied by Crack dot Com, by
8 *  Jonathan Clark, or by Sam Hocevar.
[56]9 */
10
[555]11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
[56]14
[2]15#define PARTICLE_SIZE 2            // 2x2 block of pixels
16
17class particle
18{
19public :
20  unsigned char *pict;
21  int x,y;
22  particle *left,*right,*up,*down;
23  particle(int X, int Y, int size);
[129]24  ~particle() { free(pict); }
[2]25} ;
26
27particle::particle(int X, int Y, image *im, int size);
[124]28{
29  x=X; y=Y;
30  left=right=up=down=NULL;
[129]31  pict=(unsigned char *)malloc(size*size);
[2]32}
33
34class particle_image
35{
36  int particles;
37  particle *top;
38  int size;
39public :
40  particle_image(image *im, int particle_size);       // im will be erased!
41} ;
42
43
[124]44particle_image::particle_image(image *im, int particle_size)
[2]45{
46  int x,y,py,p;
47  unsigned char *sl,*sl2;
48  top=NULL;
49  size=particle_size;
50
51  int matw=(im->width()+size-1)/size,math=(im->height()+size-1)/size;
52  particle *matrix[matw*math];
53
54
55  // break the image up into particles and store in a big matrix
[494]56  for (y=0; y<im->height(); y++)
[2]57  {
58    sl=im->scan_line(y);
59    py=y/size;
[494]60    for (x=0; x<im->width(); x++,sl+=px)
[2]61    {
62      px=x/size;
63      sl2=matrix[py*matw+px]->pict+(y%size)*size;      // address of particle image memory
64
65      int copy_size;
66
67      memset(sl2,0,size);
[124]68
[2]69      if (*sl)
70      {
[124]71    px=x/size;
72    py=y/size;
[2]73      }
74
75  }
76  if (px<0)       // couldn't find any non-blank pixels
77    particles=0;
78  else
79    add_particle_line(px,py,im);
80}
Note: See TracBrowser for help on using the repository browser.