All pastes #2056778 Raw Edit

Something

public text v1 · immutable
#2056778 ·published 2011-05-11 13:10 UTC
rendered paste body
### Game.h:

#import "SpaceManagerCocos2d.h"
#import "GameConfig.h"
#import "cocos2d.h"

typedef struct {
	int form;
	int x;
	int y;
	bool stat;	//fest
	cpShape *shape;
	cpShapeNode *node;
	int a;
	int b;
	int c;
}levelobjs;

@interface Game : CCLayer
{
	SpaceManagerCocos2d *smgr;
	levelobjs levelobj[99];
	
	cpShape *unishape;
	cpShapeNode *uninode;
	
	int curobjtodrop;
	int curobjdropped;
	bool newobjready;
	bool newobjwaiting;
	
	//grafik:
	CCSprite *sfeld;
	CCSprite *sback;
}

+(id) scene;
- (CCNode*) createBlockAt:(cpVect)pt
					width:(int)w
				   height:(int)h
					 mass:(int)mass;
-(void) gamelogic:(ccTime)dt;
-(BOOL) handleCollision:(CollisionMoment)moment arbiter:(cpArbiter*)arb space:(cpSpace*)space;
//-(void) objcoll;
-(void) dropcurobj;
-(ccColor3B) rndcolor;
@end



### Game.m:

#import "Game.h"
#import "chipmunk.h"
@interface Game (PublicMethods)
@end
@implementation Game

+(id) scene
{
	CCScene *scene = [CCScene node];
	[scene addChild:[Game node]];
	return scene;
}

- (id) init
{
	[super init];
...
...
...
levelobj[i].node.color = rndcolor;   //error: 'rndcolor' undeclared (first use in this function)

levelobj[i].node.color = rndcolor(); //warning: implicit declaration of function 'rndcolor'
                                                              //error: incompatible type for argument 1 of 'setColor:'

ccColor3B ccolor;
ccolor=rndcolor;                                //error: incompatible types in assignment

...
...
...

-(ccColor3B) rndcolor{
	unsigned char r,g,b;
	int rnd1,rnd2;
	rnd1=rand()%3 + 1; //1-3
	rnd2=rand()%2 + 1; //1-2
	
	if (rnd1==1){
		r=rand()%256;
		if(rnd2==1){
			g=rand()%256;
		}
		if(rnd2==2){
			b=rand()%256;
		}
	}
	if (rnd1==2){
		g=rand()%256;
		if(rnd2==1){
			r=rand()%256;
		}
		if(rnd2==2){
			b=rand()%256;
		}
	}
	if (rnd1==3){
		b=rand()%256;
		if(rnd2==1){
			r=rand()%256;
		}
		if(rnd2==2){
			g=rand()%256;
		}
	}
	ccColor3B color;
	color=ccc3(r, g, b);
	return color;
}
@end