Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Commander Cool Source Code Examples

View Moveable.m
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
/**
* 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
View Moveable.m
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
//
// 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
View Moveable.m
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
<?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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.