Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

save 0415 mornig

  • Loading branch information...
commit f5660275ca1acdc72f5f48bb4f7990937a56e551 1 parent 031543b
@hasifumi authored
View
11 Resources/app.js
@@ -1,9 +1,5 @@
(function() {
- var FieldScene, GAME_FPS, SCREEN_HEIGHT, SCREEN_WIDTH, TestScene, fieldScene, fireIntervalEvent, game, quicktigame2d, testScene, win;
- Ti.API.info("osname=" + Ti.Platform.osname);
- Ti.API.info("version=" + Ti.Platform.version);
- Ti.API.info("width=" + Ti.Platform.displayCaps.platformWidth);
- Ti.API.info("height=" + Ti.Platform.displayCaps.platformHeight);
+ var FieldScene, GAME_FPS, SCREEN_HEIGHT, SCREEN_WIDTH, fieldScene, fireIntervalEvent, game, quicktigame2d, win;
SCREEN_WIDTH = 320;
SCREEN_HEIGHT = 480;
GAME_FPS = 30;
@@ -16,8 +12,6 @@
game.color(1, 1, 1);
game.debug = true;
game.frame = 0;
- TestScene = require('testScene').testScene;
- testScene = new TestScene(game);
FieldScene = require('fieldScene').fieldScene;
fieldScene = new FieldScene(game);
game.addEventListener('onload', function(e) {
@@ -30,8 +24,7 @@
WINDOW_SCALE_FACTOR_X = game.screen.width / game.width;
WINDOW_SCALE_FACTOR_Y = game.screen.height / game.height;
game.pushScene(fieldScene);
- game.start();
- return fireIntervalEvent('enterframe1');
+ return game.start();
});
fireIntervalEvent = function(event) {
return setInterval(function() {
View
52 Resources/fieldScene.js
@@ -1,4 +1,4 @@
-var Map, clearMaps, map, mapjson, maps, quicktigame2d, self, updateMaps;
+var Map, Pad, Player, clearMaps, map, mapjson, maps, pad, player, quicktigame2d, self, touchend, touchstart, updateMaps;
quicktigame2d = require('com.googlecode.quicktigame2d');
self = quicktigame2d.createScene();
map = "";
@@ -30,16 +30,26 @@ updateMaps = function(_mapfile, _maps, _mapjson) {
}
return _results;
};
+Player = require('player').Player;
+player = new Player();
+Pad = require('pad').Pad;
+pad = new Pad();
+pad.color(1, 0, 0);
+pad.y = 360;
+touchstart = function(_e, _gm) {
+ return function(_e) {
+ return pad.check(_e.x, _e.y, _gm);
+ };
+};
+touchend = function() {
+ return function() {
+ return pad.clear();
+ };
+};
exports.fieldScene = function(_game) {
- var Pad, Player, WINDOW_SCALE_FACTOR_X, WINDOW_SCALE_FACTOR_Y, nextMapX, nextMapY, nextPlayerX, nextPlayerY, pad, player;
+ var WINDOW_SCALE_FACTOR_X, WINDOW_SCALE_FACTOR_Y, nextMapX, nextMapY, nextPlayerX, nextPlayerY;
updateMaps('graphics/map/map001.json', maps, mapjson);
map = maps[0];
- Player = require('player').Player;
- player = new Player();
- Pad = require('pad').Pad;
- pad = new Pad();
- pad.color(1, 0, 0);
- pad.y = 360;
player.z = 10;
pad.z = 20;
self.add(player);
@@ -154,30 +164,18 @@ exports.fieldScene = function(_game) {
};
self.addEventListener('activated', function(e) {
Ti.API.info("fieldScene activated");
- _game.addEventListener('touchstart', function(e) {
- return pad.check(e.x, e.y, _game);
- });
- _game.addEventListener('touchmove', function(e) {
- return pad.check(e.x, e.y, _game);
- });
- _game.addEventListener('touchend', function(e) {
- return pad.clear();
- });
- return _game.addEventListener('enterframe', function(e) {
+ _game.addEventListener('touchstart', touchstart(e, _game));
+ _game.addEventListener('touchmove', touchstart(e, _game));
+ _game.addEventListener('touchend', touchend());
+ return _game.addEventListener('enterframe1', function(e) {
return self.enterframe();
});
});
self.addEventListener('deactivated', function(e) {
Ti.API.info("fieldScene deactivated");
- _game.removeEventListener('touchstart', function(e) {
- return pad.check(e.x, e.y, _game);
- });
- _game.removeEventListener('touchmove', function(e) {
- return pad.check(e.x, e.y, _game);
- });
- return _game.removeEventListener('touchend', function(e) {
- return pad.clear();
- });
+ _game.removeEventListener('touchstart', touchstart(e, _game));
+ _game.removeEventListener('touchmove', touchstart(e, _game));
+ return _game.removeEventListener('touchend', touchend());
});
return self;
};
View
12 Resources/test.js
@@ -1,7 +1,15 @@
-var test;
+var map, map1, player, test, y;
test = (function() {
return Ti.API.info("test");
})(this);
(function() {
return Ti.API.info("test");
-})();
+})();
+map = require('map').Map;
+map1 = require('map');
+map1.Ti.include(map.coffee);
+self.width;
+self.heix;
+player = require('player').Player;
+player.height;
+y = player.he;
View
46 Resources/testScene.js
@@ -1,37 +1,37 @@
var testFunc;
exports.testScene = function(_game) {
- var quicktigame2d, self;
+ var quicktigame2d, testscene;
quicktigame2d = require('com.googlecode.quicktigame2d');
- self = quicktigame2d.createScene();
- self.init = function() {};
- self.addEventListener('activated', function(e) {
+ testscene = quicktigame2d.createScene();
+ testscene.init = function() {};
+ testscene.addEventListener('activated', function(e) {
Ti.API.info("testScene activated");
- self.color(1, 0, 0);
- self.logo = quicktigame2d.createSprite({
+ testscene.color(1, 0, 0);
+ testscene.logo = quicktigame2d.createSprite({
image: 'graphics/unused/a.png'
});
- self.logo.x = (_game.width * 0.5) - (self.logo.width * 0.5);
- self.logo.y = (_game.height * 0.5) - (self.logo.height * 0.5);
- self.add(self.logo);
- return self.onLogoTransform();
+ testscene.logo.x = (_game.width * 0.5) - (testscene.logo.width * 0.5);
+ testscene.logo.y = (_game.height * 0.5) - (testscene.logo.height * 0.5);
+ testscene.add(testscene.logo);
+ return testscene.onLogoTransform();
});
- self.addEventListener('enterframe', function(e) {
+ testscene.addEventListener('enterframe', function(e) {
return testFunc();
});
- self.onLogoTransform = function() {
- self.logoTransform = quicktigame2d.createTransform();
- self.logoTransform.duration = 3000;
- self.logoTransform.alpha = 1;
- self.logoTransform.easing = quicktigame2d.ANIMATION_CURVE_CUBIC_IN;
- return self.logo.transform(self.logoTransform);
+ testscene.onLogoTransform = function() {
+ testscene.logoTransform = quicktigame2d.createTransform();
+ testscene.logoTransform.duration = 3000;
+ testscene.logoTransform.alpha = 1;
+ testscene.logoTransform.easing = quicktigame2d.ANIMATION_CURVE_CUBIC_IN;
+ return testscene.logo.transform(testscene.logoTransform);
};
- self.onSceneTransform = function() {
- self.sceneTransform = quicktigame2d.createTransform();
- self.sceneTransform.duration = 3000;
- self.sceneTransform.color(0, 0, 1);
- return self.transform(self.sceneTransform);
+ testscene.onSceneTransform = function() {
+ testscene.sceneTransform = quicktigame2d.createTransform();
+ testscene.sceneTransform.duration = 3000;
+ testscene.sceneTransform.color(0, 0, 1);
+ return testscene.transform(testscene.sceneTransform);
};
- return self;
+ return testscene;
};
testFunc = function() {
return Ti.API.info("testFunc called");
View
169 coffee/app.coffee
@@ -1,8 +1,8 @@
(->
- Ti.API.info "osname="+Ti.Platform.osname
- Ti.API.info "version="+Ti.Platform.version
- Ti.API.info "width="+Ti.Platform.displayCaps.platformWidth
- Ti.API.info "height="+Ti.Platform.displayCaps.platformHeight
+ #Ti.API.info "osname="+Ti.Platform.osname
+ #Ti.API.info "version="+Ti.Platform.version
+ #Ti.API.info "width="+Ti.Platform.displayCaps.platformWidth
+ #Ti.API.info "height="+Ti.Platform.displayCaps.platformHeight
SCREEN_WIDTH = 320
SCREEN_HEIGHT = 480
@@ -18,65 +18,12 @@
game.debug = true
game.frame = 0
- TestScene = require('testScene').testScene
- testScene = new TestScene(game)
+ #TestScene = require('testScene').testScene
+ #testScene = new TestScene(game)
FieldScene = require('fieldScene').fieldScene
fieldScene = new FieldScene(game)
- #scene = quicktigame2d.createScene()
- #scene.color 1, 1, 1
-
- #maps = []
- #mapjson = ""
- #Map = require('map').Map
-
- #clearMaps = (_maps)->
- # for i in _maps
- # scene.remove i
- # i = null
- # _maps = []
-
- #updateMaps = (_mapfile, _maps, _mapjson)->
- # setTimeout ->
- # Ti.API.debug "Sleep 3 sec."
- # , 3000
- # mapfile = Ti.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory, _mapfile)
- # mapjson = JSON.parse mapfile.read().toString()
- # _mapjson = mapjson
- # for i in mapjson.layers
- # if mapjson.layers[_i].type is 'tilelayer'
- # _map = new Map _mapfile, _i
- # _maps.push _map
- # _maps[_i].z = _i
- # scene.add _maps[_i]
- # if _i is 0
- # _maps[_i].loadCollisionData()
- # _maps[_i].loadDoorData()
-
- #updateMaps 'graphics/map/map001.json', maps, mapjson
- #map = maps[0]
-
- #Player = require('player').Player
- #player = new Player()
-
- #Pad = require('pad').Pad
- #pad = new Pad()
- #pad.color 1, 0, 0
-
- #player.z = 10
- #pad.z = 20
- #scene.add player
- #scene.add pad
-
- #WINDOW_SCALE_FACTOR_X = 1
- #WINDOW_SCALE_FACTOR_Y = 1
- #nextPlayerX = 0
- #nextPlayerY = 0
- #nextMapX = 0
- #nextMapY = 0
- #player.isMoving = false
-
game.addEventListener 'onload',(e)->
screenScale = game.width / 320
game.screen =
@@ -84,44 +31,11 @@
height:game.height / screenScale
WINDOW_SCALE_FACTOR_X = game.screen.width / game.width
WINDOW_SCALE_FACTOR_Y = game.screen.height / game.height
- #Ti.API.info "game.width="+game.width
- #Ti.API.info "game.height="+game.height
- #Ti.API.info "screenScale="+screenScale
- #Ti.API.info "game.screen.width="+game.screen.width
- #Ti.API.info "game.screen.height="+game.screen.height
#pad.y = game.screen.height - pad.height
game.pushScene fieldScene
- #game.pushScene scene
- #game.pushScene testScene
game.start()
- #Ti.API.info "player.x="+player.x+",y="+player.y
- #Ti.API.info "pad.x="+pad.x+",y="+pad.y
- #Ti.API.info "map.x="+map.x+",y="+map.y
- fireIntervalEvent 'enterframe1'
-
- #game.addEventListener 'enterframe1',(e)->
- # game.frame++
- # updatePad()
- # if player.isMoving is false
- # doorTest = map.isDoor player.x, player.y
- # if doorTest
- # if mapjson.doors[doorTest - 1].toMapfile?
- # #Ti.API.info "mapjson.doors[doorTest - 1].toMapfile="+mapjson.doors[doorTest - 1].toMapfile
- # clearMaps maps
- # maps = []
- # updateMaps mapjson.doors[doorTest - 1].toMapfile, maps, mapjson
- # map = maps[0]
-
- #game.addEventListener 'touchstart',(e)->
- # pad.check e.x, e.y, game
-
- #game.addEventListener 'touchmove',(e)->
- # pad.check e.x, e.y, game
-
- #game.addEventListener 'touchend',(e)->
- # pad.clear()
fireIntervalEvent = (event)->
setInterval ->
@@ -182,75 +96,4 @@
fullscreen:true
navBarHidden:true
- #updatePad = ->
- # player.frame = (player.direction * 3) + 1
- # if player.isMoving is true
- # player.x += player.vx
- # player.y += player.vy
- # map.x -= map.vx
- # map.y -= map.vy
- # for i in maps
- # i.x = map.x
- # i.y = map.y
- # player.animate player.direction*3, 2, 250, -1
- # if ((player.vx isnt 0) and (Math.abs(player.old_x - player.x) % player.width is 0)) or ((player.vy isnt 0) and (Math.abs(player.old_y - player.y) % player.height is 0)) or ((map.vx isnt 0) and (Math.abs(map.old_x - map.x) % player.width is 0)) or ((map.vy isnt 0) and (Math.abs(map.old_y - map.y ) % player.height is 0))
- # player.isMoving = false
- # player.walk = 1
- # else
- # player.vx = 0
- # player.vy = 0
- # map.vx = 0
- # map.vy = 0
- # vx = 0
- # vy = 0
- # player.old_x = player.x
- # player.old_y = player.y
- # map.old_x = map.x
- # map.old_y = map.y
- # nextPlayerX = 0
- # nextPlayerY = 0
- # nextMapX = 0
- # nextMapY = 0
- # if pad.input.right
- # player.direction = 2
- # vx = 4
- # if pad.input.left
- # player.direction = 1
- # vx = -4
- # if pad.input.down
- # player.direction = 0
- # vy = 4
- # if pad.input.up
- # player.direction = 3
- # vy = -4
- #
- # if vx is 0
- # nextPlayerX = player.old_x
- # nextMapX = map.old_x
- # else
- # nextPlayerX = player.old_x + player.width*(vx / (Math.abs vx))
- # nextMapX = map.old_x - player.width*(vx / (Math.abs vx))
- # nextPlayer = map.hitTest(nextPlayerX, player.old_y)
- # if nextPlayer is 0 or nextPlayer is false
- # if (0 <= nextPlayerX <= (game.screen.width - player.width))
- # player.vx = vx
- # player.isMoving = true
- # else if 0 >= nextMapX and nextMapX >= -map.width + game.screen.width
- # map.vx = vx
- # player.isMoving = true
- # if vy is 0
- # nextPlayerY = player.old_y
- # nextMapY = map.old_y
- # else
- # nextPlayerY = player.old_y + player.height*(vy / (Math.abs vy))
- # nextMapY = map.old_y - player.height*(vy / (Math.abs vy))
- # nextPlayer = map.hitTest(player.old_x, nextPlayerY)
- # if nextPlayer is 0 or nextPlayer is false
- # if (0 <= nextPlayerY <= (game.screen.height - player.height))
- # player.vy = vy
- # player.isMoving = true
- # else if 0 >= nextMapY and nextMapY >= -map.height + game.screen.height
- # map.vy = vy
- # player.isMoving = true
-
)()
View
82 coffee/fieldScene.coffee
@@ -31,50 +31,29 @@ updateMaps = (_mapfile, _maps, _mapjson)->
_maps[_i].loadCollisionData()
_maps[_i].loadDoorData()
+Player = require('player').Player
+player = new Player()
+
+Pad = require('pad').Pad
+pad = new Pad()
+pad.color 1, 0, 0
+pad.y = 360
+
+touchstart = (_e, _gm)->
+ (_e)->
+ #Ti.API.info "fieldScene touchstart function"
+ #Ti.API.info "_e.x="+_e.x+",_e.y="+_e.y
+ pad.check _e.x, _e.y, _gm
+
+touchend = ->
+ ->
+ pad.clear()
+
exports.fieldScene = (_game)->
- #quicktigame2d = require 'com.googlecode.quicktigame2d'
- #self = quicktigame2d.createScene()
-
- #self.init = ->
- #map = ""
- #maps = []
- #mapjson = ""
- #Map = require('map').Map
-
- #clearMaps = (_maps)->
- # for i in _maps
- # self.remove i
- # i = null
- # _maps = []
-
- #updateMaps = (_mapfile, _maps, _mapjson)->
- # setTimeout ->
- # Ti.API.debug "Sleep 3 sec."
- # , 3000
- # mapfile = Ti.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory, _mapfile)
- # mapjson = JSON.parse mapfile.read().toString()
- # _mapjson = mapjson
- # for i in mapjson.layers
- # if mapjson.layers[_i].type is 'tilelayer'
- # _map = new Map _mapfile, _i
- # _maps.push _map
- # _maps[_i].z = _i
- # self.add _maps[_i]
- # if _i is 0
- # _maps[_i].loadCollisionData()
- # _maps[_i].loadDoorData()
updateMaps 'graphics/map/map001.json', maps, mapjson
map = maps[0]
- Player = require('player').Player
- player = new Player()
-
- Pad = require('pad').Pad
- pad = new Pad()
- pad.color 1, 0, 0
- pad.y = 360
-
player.z = 10
pad.z = 20
self.add player
@@ -173,25 +152,18 @@ exports.fieldScene = (_game)->
self.addEventListener 'activated',(e)->
Ti.API.info "fieldScene activated"
- _game.addEventListener 'touchstart',(e)->
- #Ti.API.info "fieldScene touchstart"
- #Ti.API.info "e.x="+e.x+",e.y="+e.y
- pad.check e.x, e.y, _game
- _game.addEventListener 'touchmove',(e)->
- pad.check e.x, e.y, _game
- _game.addEventListener 'touchend',(e)->
- pad.clear()
- _game.addEventListener 'enterframe',(e)->
+ #_game.addEventListener 'touchstart',(e)->
+ # pad.check e.x, e.y, _game
+ _game.addEventListener 'touchstart', touchstart(e, _game)
+ _game.addEventListener 'touchmove', touchstart(e, _game)
+ _game.addEventListener 'touchend', touchend()
+ _game.addEventListener 'enterframe1',(e)->
self.enterframe()
- #self.addEventListener 'enterframe', self.enterframe()
self.addEventListener 'deactivated',(e)->
Ti.API.info "fieldScene deactivated"
- _game.removeEventListener 'touchstart',(e)->
- pad.check e.x, e.y, _game
- _game.removeEventListener 'touchmove',(e)->
- pad.check e.x, e.y, _game
- _game.removeEventListener 'touchend',(e)->
- pad.clear()
+ _game.removeEventListener 'touchstart', touchstart(e, _game)
+ _game.removeEventListener 'touchmove', touchstart(e, _game)
+ _game.removeEventListener 'touchend', touchend()
self
View
32 coffee/test.coffee
@@ -6,4 +6,36 @@ test = (->
Ti.API.info "test"
)()
+map = require('map').Map
+map1 = require 'map'
+
+map1.
+
+Ti.include(map.coffee)
+
+self.width
+self.heix
+
+player = require('player').Player
+player.height
+y = player.he
+
+player.width:wq
+Ti.include(map.coffee)
+
+updateMaps
+k
+map.upda:q
+mapin
+
+player.width:q
+:
+testscene = require('testScene').tests
+
+testscene.logoTra
+testscene.wid
+
+loga:
+
+til
View
46 coffee/testScene.coffee
@@ -1,35 +1,35 @@
exports.testScene = (_game)->
quicktigame2d = require 'com.googlecode.quicktigame2d'
- self = quicktigame2d.createScene()
- self.init = ->
- self.addEventListener 'activated',(e)->
+ testscene = quicktigame2d.createScene()
+ testscene.init = ->
+ testscene.addEventListener 'activated',(e)->
Ti.API.info "testScene activated"
- self.color 1, 0, 0
- #self.onSceneTransform()
- self.logo = quicktigame2d.createSprite
+ testscene.color 1, 0, 0
+ #testscene.onSceneTransform()
+ testscene.logo = quicktigame2d.createSprite
image:'graphics/unused/a.png'
- self.logo.x = (_game.width * 0.5) - (self.logo.width * 0.5)
- self.logo.y = (_game.height * 0.5) - (self.logo.height * 0.5)
- self.add self.logo
- self.onLogoTransform()
- self.addEventListener 'enterframe',(e)->
+ testscene.logo.x = (_game.width * 0.5) - (testscene.logo.width * 0.5)
+ testscene.logo.y = (_game.height * 0.5) - (testscene.logo.height * 0.5)
+ testscene.add testscene.logo
+ testscene.onLogoTransform()
+ testscene.addEventListener 'enterframe',(e)->
#Ti.API.info "testScene enterframed"
testFunc()
- self.onLogoTransform = ->
- self.logoTransform = quicktigame2d.createTransform()
- self.logoTransform.duration = 3000
- self.logoTransform.alpha = 1
- self.logoTransform.easing = quicktigame2d.ANIMATION_CURVE_CUBIC_IN
- self.logo.transform self.logoTransform
+ testscene.onLogoTransform = ->
+ testscene.logoTransform = quicktigame2d.createTransform()
+ testscene.logoTransform.duration = 3000
+ testscene.logoTransform.alpha = 1
+ testscene.logoTransform.easing = quicktigame2d.ANIMATION_CURVE_CUBIC_IN
+ testscene.logo.transform testscene.logoTransform
- self.onSceneTransform = ->
- self.sceneTransform = quicktigame2d.createTransform()
- self.sceneTransform.duration = 3000
- self.sceneTransform.color 0, 0, 1 # blue
- self.transform self.sceneTransform
+ testscene.onSceneTransform = ->
+ testscene.sceneTransform = quicktigame2d.createTransform()
+ testscene.sceneTransform.duration = 3000
+ testscene.sceneTransform.color 0, 0, 1 # blue
+ testscene.transform testscene.sceneTransform
- self
+ testscene
testFunc = ->
Ti.API.info "testFunc called"

0 comments on commit f566027

Please sign in to comment.
Something went wrong with that request. Please try again.