Skip to content

Instantly share code, notes, and snippets.

@hackfrag
Created June 22, 2012 11:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hackfrag/2972219 to your computer and use it in GitHub Desktop.
Save hackfrag/2972219 to your computer and use it in GitHub Desktop.
Commander Cool Source Code Examples
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" width="30" height="20" tilewidth="32" tileheight="32">
<properties>
<property name="BackgroundImage" value="noon"/>
<property name="Weather" value="sparkle"/>
<property name="BackgroundMusic" value="cc_background01.mp3"/>
</properties>
<tileset firstgid="1" name="cc_map_tileset_v3" tilewidth="32" tileheight="32">
<image source="cc_map_tileset_v3.png" width="1024" height="1024"/>
</tileset>
<layer name="Background" width="30" height="20">
<data encoding="base64" compression="gzip">
H4sIAAAAAAAAA2NgGAWjYBSMglGADvgZGRgEgFiQEb8YKfpp7b6BdtNIAVlImN72oWN620eJ/QJALEhnLATEBkBsSGdsBMQAt2b9pGAJAAA=
</data>
</layer>
<layer name="Foreground" width="30" height="20">
<data encoding="base64" compression="gzip">
H4sIAAAAAAAAA+3BMQEAAADCoPVPbQlPoAAAeBoqs0udYAkAAA==
</data>
</layer>
<objectgroup color="#f9f8ff" name="Collision" width="30" height="20">
<object x="0" y="576" width="960" height="64"/>
<object x="256" y="544" width="352" height="32"/>
<object x="320" y="512" width="224" height="32"/>
<object x="384" y="480" width="96" height="32"/>
</objectgroup>
<objectgroup color="#018fff" name="Entities" width="30" height="20">
<object name="Player" type="Player" x="32" y="512" width="64" height="64"/>
</objectgroup>
<objectgroup color="#00a407" name="Objects" width="30" height="20">
<object name="Checkpoint" type="Checkpoint" x="864" y="544" width="32" height="32"/>
<object name="Diamond" type="Diamond" x="416" y="448" width="32" height="32"/>
</objectgroup>
<objectgroup color="#a40001" name="Particles" width="30" height="20"/>
</map>
/**
* Expose javascript methods
*/
@implementation Moveable
- (SEL)selectorForJavascriptMethod:(NSString *)methodName {
if([methodName isEqualToString:@"drink"]) {
return @selector(drink);
} else if([methodName isEqualToString:@"jump"]) {
return @selector(jump);
} else if([methodName isEqualToString:@"shoot"]) {
return @selector(shoot);
} else if([methodName isEqualToString:@"hit"]) {
return @selector(hitWithDamage:);
}
return nil;
}
- (JSStaticFunction*)staticsMethodes {
static JSStaticFunction staticFunctions[] = {
{ "drink", [self callback], NULL },
{ "jump", [self callback], NULL },
{ "shoot", [self callback], NULL },
{ "hit", [self callback], NULL },
{ 0, 0, 0 }
};
return staticFunctions;
}
@end
//
// Object.h
// CommanderCool
//
// Created by Florian Strauß & Christian Janzen on 23.10.11.
// Copyright (c) 2011 Cool Corporation. All rights reserved.
//
#import "EntityAbstract.h"
@interface Object : EntityAbstract
/**
damage caused e.g. a bullet or something
*/
@property int damage;
/**
health plus e.g. a potion or an apple.
*/
@property int cure;
/**
Score gain e.g. a gold/silver coin.
*/
@property int score;
/**
Can the object picked up in the inventory?
*/
@property BOOL pickable;
/**
Is the object colliable?
*/
@property BOOL collideable;
/**
Remove object after collison?
*/
@property BOOL removeAfterCollision;
/**
Trigger collsion only once
*/
@property BOOL triggerCollsionOnce;
/**
Name of the Trigger.
The Trigger is called when a entity collide with the object.
When interval is set the trigger is called every interval.
Example: Player::drink or LevelScene::finish
*/
@property (nonatomic, retain) NSString *trigger;
/**
Javascript code
*/
@property (nonatomic, retain) NSString *script;
/**
Soundfile which is played when a entity collide.
@Todo Soundfile should preload on Startup
*/
@property (nonatomic, retain) NSString *sound;
@property (nonatomic, retain) NSMutableDictionary *properties;
/**
Interval in seconds
When interval is higher than 0 the collisionWithEntity
is called every interval.
*/
@property int interval;
@property int impulse;
- (void)seedWithProperties:(NSDictionary *)properties;
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment