Permalink
Browse files

Day 1 code

  • Loading branch information...
1 parent e012a21 commit 6c879b62515a263d5e6c57cf886a28243e6fa6bb Sergej Tatarincev committed Aug 25, 2012
View
@@ -8,6 +8,6 @@
<script type='text/javascript' data-main='src/main.js' src='lib/require.js'></script>
</head>
<body>
- <canvas id='gameCanvas' width='800' height='450'></canvas>
+ <canvas id='gameCanvas' width='640' height='480'></canvas>
</body>
</html>
@@ -34749,6 +34749,7 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{
}
// PARSE <map><property>
+ this.setParentElement(cc.TMXPropertyMap);
var properties = mapXML.querySelectorAll('map > properties > property')
if (properties) {
for (i = 0; i < properties.length; i++) {
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Deleted file not rendered
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<map version="1.0" orientation="orthogonal" width="32" height="24" tilewidth="20" tileheight="20">
+ <properties>
+ <property name="leftPortal" value="resources/level1.tmx"/>
+ </properties>
+ <tileset firstgid="1" name="beach_bg" tilewidth="20" tileheight="20">
+ <image source="beach_bg.png" width="640" height="360"/>
+ </tileset>
+ <tileset firstgid="577" name="sleepingSailor" tilewidth="20" tileheight="20">
+ <image source="sleepingSailor.png" width="140" height="120"/>
+ </tileset>
+ <tileset firstgid="619" name="tiles" tilewidth="20" tileheight="20">
+ <image source="tiles.png" width="40" height="20"/>
+ </tileset>
+ <tileset firstgid="621" name="beach_fg" tilewidth="20" tileheight="20">
+ <image source="beach_fg.png" width="160" height="300"/>
+ </tileset>
+ <layer name="background" width="32" height="24">
+ <data encoding="base64" compression="gzip">
+ H4sIAAAAAAAAA+3VAxcQBgCF0Wzbtm3btm23vGzbtm1s2bbtlt3Sbr9jfefcn/DOCxDgd7/7/xaQQAQmCEEJRnBCEJJQhCYMYQlHeCIQkUhEJgpRiUZ0YhCTWMQmDnGJR3wSkJBEJCYJSUlGclKQklSkJg1pSUd6MpCRTGQmC1nJRnZykJNc5CYPeclHfgpQkEIUpghFKUZxSlCSUpSmDGUpR3kqUJFKVKYKValGdWpQk1rUpg51qUd9GtCQRjSmCU1pRnNa0JJWtKYNbWlHezrQkU505g+60JVudKcHPenFn/SmD33pR38GMJBBDGYIQxnGcEYwklGMZgxjGcd4JjCRSUxmClOZxnRmMJNZzGYOc5nHfBawkEUsZglLWcZyVrCSVaxmDWtZx3o2sJFNbGYLW9nGdnawk138xd/sZg972cd+DnCQQxzmCEc5xnFOcJJTnOYMZznHeS5wkUtc5gpXucZ1bnCTW9zmDne5x30e8JBHPOYJT3nGPzznBS95xWve8JZ3vOcDH/nEZ77wL1/5xnd+8JNf4w9IIAIThKAEIzghCEkoQhOGsIQjPBGISCQiE4WoRCM6MYhJLGITh7jEIz4JSEgiEpOEpCQjOSlISSpSk4a0pCM9GchIJjKThaxkIzs5yEkucpOHvOQjPwUoSCEKU4SiFKM4JShJKUpThrKUozwVqEglKlOFqlSjOjWoSS1qU4e61KM+DWhIIxrThKY0ozktaEkrWtOGtrSjPR3oSCc68wdd6Eo3utODnvTiT3rTh770oz8DGMggBjOEoQxjOCMYyShGM4axjGM8E5jIJCYzhalMYzozmMksZjOHucxjPgtYyCIWs4SlLGM5K1jJKlazhrWsYz0b2MgmNrOFrWxjOzvYyS7+4m92s4e97GM/BzjIIQ5zhKMc4zgnOMkpTnOGs5zjPBe4yCUuc4WrXOM6N7jJLW5zh7vc4z4PeMgjHvOEpzzjH57zgpe84jVveMs73vOBj3ziM1/4l6984zs/+Mmv4w9IIAIThKAEIzghCEkoQhOGsIQjPBGISCQiE4WoRCM6MYhJLGITh7jEIz4JSEgiEpOEpCQjOSlISSpSk4a0pCM9GchIJjKThaxkIzs5yEkucpOHvOQjPwX4D4PvtToADAAA
+ </data>
+ </layer>
+ <layer name="sleepingSalor" width="32" height="24">
+ <data encoding="base64" compression="gzip">
+ H4sIAAAAAAAAA+3NtQ0DARAAwdd3ZmZmZuy/AE8V5+RWmniLIsuyLMuyLL5KWRRVatRp0KRVxvzbPh269OgzYBj0H/mMmTBlxpxF0H/ps2LNhi079kH/g8+RE2cuXLkF/e8+D568ePPhG/T/Zz+04JHHAAwAAA==
+ </data>
+ </layer>
+ <layer name="walls" width="32" height="24">
+ <data encoding="base64" compression="gzip">
+ H4sIAAAAAAAAA+3PVw6CAAAE0ZVDIu3+iRSlqPQyt4CEneT970rOOeecc+5uhYH0RIQYCVJkwdnLpNdDylGgRIU3PqjRoEWHL374o8eAERNmLFixYYcu8O/sDjAefpwADAAA
+ </data>
+ </layer>
+ <objectgroup name="objects" width="32" height="24">
+ <object name="Spawn" x="166" y="365" width="30" height="46"/>
+ </objectgroup>
+ <layer name="foreground" width="32" height="24">
+ <data encoding="base64" compression="gzip">
+ H4sIAAAAAAAAA+3NR0qdARhA0cfbrx07dmIs2LFjxyQqduzYsaOxoImKfSOeFTjzG/0XzvimUklJSd9VRjqVyiSLbHLIJS8d88/3KaCQIoopoTToX+ZTTgWVVFFNTdD/h08tP6mjngYag/5NPs200Eob7XQE/Tt9uuimh1766A/6D/gMMsQwI4wyFvQf9/nFb/4wwSRTQf9pnxlmmWOeBRaD/ks+y6ywyhrrbAT9N3222GaHXfbYD/of+BxyxDEnnHIW9D/3ueAvl1xxzU3Q/9bnjn/8554HHoP+Tz7PvPDKG+98BP2Tvu4TLjnfxgAMAAA=
+ </data>
+ </layer>
+</map>
View
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<map version="1.0" orientation="orthogonal" width="48" height="24" tilewidth="20" tileheight="20">
+ <properties>
+ <property name="rightPortal" value="resources/level0.tmx"/>
+ </properties>
+ <tileset firstgid="1" name="jungle_bg" tilewidth="20" tileheight="20">
+ <image source="jungle_bg.png" width="960" height="360"/>
+ </tileset>
+ <tileset firstgid="865" name="jungle_fg" tilewidth="20" tileheight="20">
+ <image source="jungle_fg.png" width="180" height="360"/>
+ </tileset>
+ <tileset firstgid="1027" name="tiles2" tilewidth="20" tileheight="20">
+ <image source="tiles2.png" width="40" height="20"/>
+ </tileset>
+ <layer name="background" width="48" height="24">
+ <data encoding="base64" compression="gzip">
+ H4sIAAAAAAAAA+3X4xIYhhKA0ca2bdu2bdt2GqdJGtu2bdu2baOx2ZOnuD9uv5nzCDu7+8cf//Vf/78FICCBCEwQghKM4IQgJKEITRjCEo7wRCAikYhMFKISjejEICaxiE0c4hKP+CQgIYlITBKSkozkpCAlqUhNGtKSjvRkICOZyEwWspKN7OQgJ7nITR7yko/8FKAghShMEYpSjOKUoCSlKE0ZylKO8lSgIpWoTBWqUo3q1KAmtahNHepSj/o0oCGNaEwTmtKM5rSgJa1oTRva0o72dKAjnejMn3ShK93oTg960ove/EUf+tKPv+nPAAYyiMEMYSjDGM4IRjKK0YxhLOMYzwQmMonJTGEq05jODGYyi9nMYS7zmM8CFrKIxSxhKctYzgpWsorVrGEt61jPBjayic1sYSvb2M4OdrKL3exhL/vYzwEOcojDHOEoxzjOCU5yitOc4SznOM8FLnKJy1zhKte4zg1ucovb3OEu97jPAx7yiMc84SnPeM4L/uElr3jNG97yjvd84COf+MwXvvKN7/zgJ7/4PfwBCEggAhOEoAQjOCEISShCE4awhCM8EYhIJCIThahEIzoxiEksYhOHuMQjPglISCISk4SkJCM5KUhJKlKThrSkIz0ZyEgmMpOFrGQjOznISS5yk4e85CM/BShIIQpThKIUozglKEkpSlOGspSjPBWoSCUqU4WqVKM6NahJLWpTh7rUoz4NaEgjGtOEpjSjOS1oSSta04a2tKM9HehIJzrzJ13oSje604Oe9KI3f9GHvvTjb/ozgIEMYjBDGMowhjOCkYxiNGMYyzjGM4GJTGIyU5jKNKYzg5nMYjZzmMs85rOAhSxiMUtYyjKWs4KVrGI1a1jLOtazgY1sYjNb2Mo2trODnexiN3vYyz72c4CDHOIwRzjKMY5zgpOc4jRnOMs5znOBi1ziMle4yjWuc4Ob3OI2d7jLPe7zgIc84jFPeMoznvOCf3jJK17zhre84z0f+MgnPvOFr3zjOz/4yS9+L/4ABCQQgQlCUIIRnBCEJBShCUNYwhGeCEQkEpGJQlSiEZ0YxCQWsYlDXOIRnwQkJBGJSUJSkpGcFKQkFalJQ1rSkZ4MZCQTmclCVrKRnRzkJBe5yUNe8pGfAhSkEIUpQlGKUZwSlKQUpSlDWcpRngpUpBKVqUJVqlGdGtSkFrWpQ13qUZ8GNKQRjWlCU5rRnBa0pBWtaUNb2tGeDnSkE535ky50pRvd6UFPetGbv+hDX/rxN/0ZwEAGMZghDGUYwxnBSEYxmjGMZRzjmcBEJjGZKUxlGtOZwUxmMZs5zGUe81nAQhaxmCUsZRnLWcFKVrGaNaxlHevZwEY2sZktbGUb29nBTnaxmz3sZR/7OcBBDnGYIxzlGMc5wUlOcZoznOUc57nARS5xmStc5RrXucFNbnGbO9zlHvd5wEMe8ZgnPOUZz3nBP7zkFa95w1ve8Z4PfOQTn/nCV77xnR/85Be/j/4ABCQQgQlCUIIRnBCEJBShCUNYwhGeCEQkEpGJQlSiEZ0YxCQWsYlDXOIRnwQkJBGJSUJSkpGcFKQkFalJQ1rSkZ4MZCQTmclCVrKRnRzkJBe5yUNe8pGfAhSkEIUpQlGKUZwSlKQUpSlDWcpRngpUpBKVqUJVqlGdGtSkFrWpQ13qUf/30/Vf/9P+BWjhuiwAEgAA
+ </data>
+ </layer>
+ <layer name="walls" width="48" height="24">
+ <data encoding="base64" compression="gzip">
+ H4sIAAAAAAAAA+3DsQkAAAgDsIL9/2avcBASSAIAAABwa/p7n182f99IABIAAA==
+ </data>
+ </layer>
+ <layer name="foreground" width="48" height="24">
+ <data encoding="base64" compression="gzip">
+ H4sIAAAAAAAAA+3PZ1fPARzG4R/932h2MkO27FKZySoyouxZZlFGlJ29V0hKZijj8gYcz/oe53+fcz3/3EmSXnr/5zIzkmQQgxnCUIYxPKO/y/5tf+sfQVbwHyP1ZTOK0YxhLOMYT07w/gn6JjKJXCYzhalMY3rw/hn6ZjKLPGYzh7nMY37w/gX6FpJPAYsopIhiFgfvX6JvKctYzgpKWEkpq4L3r9a3hrWso4xy1rOBiuD9G/VtYjNbqGQr26iiOnj/dn072MkudrOHvexjf/D+A/oOcogaajnMEY5yLHj/cX0nqKOek5yigUZOB+8/o+8s52jiPBdopoWLwfsv6bvMFa5yjeu0coObwftv6bvNHe5yj/s84CGPgvc/1veEpzzjOS9o4yWvgve/1tfOGzp4SyddvKM7eP97fR/4yCc+84UevvIteP93fb308YOf/PrTnEqSAQxM9Xdher8ByF/4HwASAAA=
+ </data>
+ </layer>
+</map>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -1,4 +1,4 @@
-require(['cocos2d', 'scenes/HelloWorldScene'], function(cc, HelloWorldScene) {
+require(['cocos2d', 'scenes/GameScene'], function(cc, GameScene) {
'use strict';
cc.AppDelegate = cc.Application.extend({
@@ -16,7 +16,7 @@ require(['cocos2d', 'scenes/HelloWorldScene'], function(cc, HelloWorldScene) {
director.setDisplayFPS(true);
director.setAnimationInterval(1.0 / 60);
- var scene = HelloWorldScene.node();
+ var scene = GameScene.scene();
director.runWithScene(scene);
return true;
View
@@ -0,0 +1,60 @@
+define(['cocos2d'], function (cc) {
+ 'use strict';
+ /** @const */ var GRAVITY = -160;
+ /** @const */ var X_ACCELL = 1000;
+
+ var Darwin = cc.Sprite.extend({
+ ctor: function() {
+ this.initWithFile('resources/Darwin.png');
+ this.velocity = cc.ccp(0, 0);
+ this.xAccel = 0;
+ this.onGround = false;
+ this.setAnchorPoint(cc.ccp(0.5, 0));
+ },
+
+ moveAlongX: function(dt) {
+ var velocityStep = this.xAccel * dt;
+ this.velocity.x = (this.velocity.x + velocityStep) * 0.9;
+ var positionStep = this.velocity.x * dt;
+ this.setPosition(cc.ccp(this.getPosition().x + positionStep, this.getPosition().y));
+ },
+
+ moveAlongY: function(dt) {
+ var velocityStep = GRAVITY * dt;
+ this.velocity.y += velocityStep;
+ var positionStep = this.velocity.y * dt;
+ this.setPosition(cc.ccp(this.getPosition().x, this.getPosition().y + positionStep));
+ },
+
+ collisionBox: function() {
+ var pos = this.getPosition();
+ var size = this.getContentSize();
+ return cc.RectMake(pos.x - 15, pos.y, 30, size.height);
+ },
+
+ moveRight: function() {
+ this.xAccel = X_ACCELL;
+ },
+
+ moveLeft: function() {
+ this.xAccel = -X_ACCELL;
+ },
+
+ stop: function() {
+ this.xAccel = 0;
+ },
+
+ jump: function() {
+ if (this.onGround) {
+ this.velocity.y = 180;
+ this.onGround = false;
+ }
+ }
+ });
+
+ Darwin.create = function() {
+ return new Darwin();
+ };
+
+ return Darwin;
+});
View
@@ -27,7 +27,17 @@ require(['domReady', 'cocos2d', 'AppDelegate'], function(domReady, cc) {
};
loader.preload([
- {type: 'image', src: 'resources/HelloWorld.png'}
+ {type: 'image', src: 'resources/beach_bg.png'},
+ {type: 'image', src: 'resources/beach_fg.png'},
+ {type: 'image', src: 'resources/jungle_bg.png'},
+ {type: 'image', src: 'resources/jungle_fg.png'},
+ {type: 'image', src: 'resources/sleepingSailor.png'},
+ {type: 'image', src: 'resources/tiles.png'},
+ {type: 'image', src: 'resources/tiles2.png'},
+ {type: 'image', src: 'resources/Darwin.png'},
+
+ {type: 'tmx', src: 'resources/level0.tmx'},
+ {type: 'tmx', src: 'resources/level1.tmx'}
]);
});
});
Oops, something went wrong.

0 comments on commit 6c879b6

Please sign in to comment.