Permalink
Browse files

Merge branch 'master' of git@github.com:gilangcp/VN-Engine.git

Conflicts:
	vnEngine.js
  • Loading branch information...
2 parents 97e1f6c + 1dc0e57 commit 38cf0f4a4e681ca3af0e20e7f131cffb66c68696 @gilangcp committed Apr 21, 2012
View
@@ -1,15 +1,35 @@
var resourceList = new Array;
- resourceList.push({type :'img',url :'resource/image/1.jpg',imageLabel :'s1'});
- resourceList.push({type :'img',url :'resource/image/2.jpg',imageLabel :'s2'});
+
+ //character
resourceList.push({type :'img',url :'resource/image/chara/rina1.png',imageLabel :'charaRina1'});
resourceList.push({type :'img',url :'resource/image/chara/clara1.png',imageLabel :'charaClara1'});
resourceList.push({type :'img',url :'resource/image/chara/lily1.png',imageLabel :'charaLily1'});
+
+ //BGM
resourceList.push({type :'snd',url :'resource/sound/ending.mp3', soundLabel : 'ending'});
resourceList.push({type :'snd',url :'resource/sound/opening.mp3',soundLabel : 'menuBGM'});
resourceList.push({type :'snd',url :'resource/sound/sad.mp3',soundLabel : 'sad'});
resourceList.push({type :'snd',url :'resource/sound/normal.mp3',soundLabel : 'normal'});
+ resourceList.push({type :'snd',url :'resource/sound/awang.mp3',soundLabel : 'awang'});
+
+
+ //Effect
resourceList.push({type :'snd',url :'resource/sfx/click.wav',soundLabel : 'sfxClick'});
- resourceList.push({type :'img',url :'resource/image/3.jpg' , imageLabel:'menu'});
- resourceList.push({type :'img',url :'resource/image/4.jpg' , imageLabel:'settings'});
- resourceList.push({type :'img',url :'resource/image/4.jpg' , imageLabel:'save'});
+
+ //game background
+ resourceList.push({type:'img',url :'resource/image/background/1.jpg',imageLabel :'roomDay'});
+ resourceList.push({type:'img',url :'resource/image/background/5.jpg',imageLabel :'roomNight'});
+ resourceList.push({type:'img',url :'resource/image/background/6.jpg',imageLabel :'roadDay'});
+
+
+
+ //Special - image label must exist
+ resourceList.push({type :'img',url :'resource/image/background/3.jpg' , imageLabel:'menu'});
+ resourceList.push({type :'img',url :'resource/image/background/4.jpg' , imageLabel:'settings'});
+ resourceList.push({type :'img',url :'resource/image/background/4.jpg' , imageLabel:'save'});
+
+ //Other (splash screen , etc)
+ resourceList.push({type :'img',url :'resource/image/other/1.jpg' , imageLabel:'logo'});
+
+ //video
resourceList.push({type :'vid',url :'resource/video/wongit.webm',videoLabel:'wongIT'});
View
Deleted file not rendered
View
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
@@ -10,7 +10,7 @@ function ResourceManager(stage) {
this.resource =new Array;
this.loader.addProgressListener(this.resProgressListener);
this.loader.addCompletionListener(this.resCompleteListener);
- this.loadResource();
+ this.loadResource();
}
this.loadResource = function(){
@@ -53,11 +53,11 @@ function ResourceManager(stage) {
}
this.getResource = function(label) {
- for (var i = 0; i < self.resource.length; i++) {
+ for (var i = 0; i < self.resource.length; i++) {
if (self.resource[i].label == label) {
return self.resource[i];
}
}
- return -1;
+ return false;
}
}
View
@@ -1,47 +1,82 @@
var script = new Array;
- script.push({type:'playBGM',soundLabel: 'menuBGM'});
- script.push({type:'changeBackground',imageLabel:'s1'});
- script.push({type:'delay',ms:3000});
+ //splash screen must be defined before init menu
+ script.push({type:'changeBackground',imageLabel:'logo'});
+ script.push({type:'delay',ms:2000});
script.push({type:'playVideo',videoLabel:'wongIT'});
-
script.push({type:'initMenu'});
+
+ //Game start point always start with "startGame" jumpLabel
script.push({type:'addJumpLabel', jumpLabel:'startGame'});
- script.push({type:'startGame'});
+
script.push({type:'addFlag',flagLabel :'F1',flagValue:'false'});
script.push({type:'addFlag',flagLabel :'F2',flagValue:'false'});
+
script.push({type:'addJumpLabel', jumpLabel:'A1'});
+
script.push({type:'if',
op:'==',
exp1 : {type:'getFlag',flagLabel:"F2"},
exp2:'true',
right : {type:'editFlag',flagLabel:"F1", flagValue:'true'},
wrong :undefined});
- script.push({type:'changeBackground',imageLabel:'s1'});
+
+
+ script.push({type:'playBGM',soundLabel: 'awang'});
+ script.push({type:'changeBackground',imageLabel:{color:Graphics.getRGB(0,0,0)}});
+ script.push({type:'speak' ,character :'Aku', speak:'Aku merasa aneh'});
+ script.push({type:'speak' ,character :'Aku', speak:'Tubuhku terasa berat'});
+ script.push({type:'speak' ,character :'Aku', speak:'Aku bisa melihat tubuhku terbuat dari batu'});
+ script.push({type:'speak' ,character :'Aku', speak:'Ada apa ini? dengan panik aku meraba tubuhku'});
+ script.push({type:'speak' ,character :'Aku', speak:'Kenapa? kenapa tubuhku terbuat dari batu?'});
+ script.push({type:'speak', character: 'Aku', speak: 'Aku mendengar teriakan teman-temanku'});
+ script.push({type:'speak' , character : 'Aku' , speak: 'Aku mencoba melihat sekelilingku'});
+ script.push({type:'speak',character:'Aku',speak: 'Yang aku lihat hanyalah hitam'});
script.push({type:'playBGM',soundLabel: 'normal'});
- script.push({type:'speak' ,character :'Gilang', speak: 'kimochi :)'});
- script.push({type:'showCharacter',imageLabel :'charaRina1' , position: 'left'});
- script.push({type:'pauseScript'});
+ script.push({type:'changeBackground',imageLabel:'roomNight'});
+
+ script.push({type: 'speak' , character:'Aku', speak:'Aku terbangun dari mimpiku'});
+ script.push({type:'speak' ,character :'Aku', speak: 'Tubuhku masih kaku tidak bisa digerakan'});
+ script.push({type:'speak' ,character :'Aku', speak: 'Dengan perlahan aku membuka jendala kamar ku'});
+ script.push({type:'changeBackground',imageLabel:'roomDay'});
+ script.push({type:'speak' ,character :'Aku', speak: 'Cahaya matahari yang menyilaukan masuk kedalam kamarku'});
+ script.push({type:'speak' ,character :'Aku', speak: 'Tanpa sadar aku menutup mataku yang masih beradaptasi dengan sinar fajar'});
+ script.push({type: 'speak' , character:'Aku', speak:'hmm..'});
+ script.push({type: 'speak' , character:'Aku', speak:'Mimpi yang aneh'});
+ script.push({type: 'speak' ,character:'Aku' , speak: 'Apa yang harus aku lakukan sekarang?'});
+ script.push({type: 'speak' , character:'Aku', speak:'hmm..'});
+ script.push({type:'speak' ,character: 'Aku' ,speak: 'Aku bersiap untuk berangkat ke kampus'});
+
+ script.push({type:'changeBackground',imageLabel:'roadDay'});
+
+ script.push({type:'speak' ,character: 'Aku' ,speak: 'Lanjut Next time =p'});
+
+
+
+
+
+
+
+
+
+/*
script.push({type:'playBGM',soundLabel: 'normal'});
script.push({type:'showCharacter',imageLabel :'charaClara1', position: 'center'});
script.push({type:'pauseScript'});
script.push({type:'playBGM',soundLabel: 'normal'});
script.push({type:'showCharacter',imageLabel :'charaLily1',position:'right'});
script.push({type:'pauseScript'});
- script.push({type:'changeBackground',imageLabel:'s2'});
- script.push({type:'speak', character :'rina',speak : 'apaan pagi-pagi udah halo? nya\
- aaaaaaaaaaaaaaafwrhgwerheherherherhwerherherh\
- erhwerhwerhwerhwergerguwerhgiherughierwrhghweri\
- erhwerhiererighiergierhgwerigheruhgtrhgierghegjo'});
- script.push({type:'changeBackground',imageLabel:'s1'});
+ script.push({type:'changeBackground',imageLabel:'2'});
+ script.push({type:'speak', character :'rina',speak : 'apaan pagi-pagi udah halo?'});
+ script.push({type:'changeBackground',imageLabel:'background2'});
script.push({type:'pauseScript'});
script.push({type:'hideCharacter',position :'right'});
script.push({type:'pauseScript'});
script.push({type:'hideCharacter',position :'left'});
script.push({type:'pauseScript'});
- script.push({type:'changeBackground',imageLabel:'s2'});
+ script.push({type:'changeBackground',imageLabel:'background2'});
script.push({type:'pauseScript'});
script.push({type:'speak',character : 'gilang' , speak : 'Eh? semuanya pada kemana?'});
script.push({type:'hideCharacter',position :'center'});
@@ -52,9 +87,12 @@ var script = new Array;
exp2:'true',
right : undefined,
wrong :[{type :'editFlag',flagLabel:'F2',flagValue:'true'},{type :'jumpTo',jumpLabel:'A1'}]});
+
script.push({type:'option' , optionList : [
{caption : 'Ulangi' , perform: {type : 'jumpTo' , jumpLabel:'A1'}},
{caption :'Selesai' , perform: undefined}
]});
+
script.push({type:'playBGM',soundLabel: 'ending'});
script.push({type: 'speak', character:'Gilang',speak:'apa yang terjadi? gamenya selesai?'});
+*/
View
@@ -8,6 +8,7 @@ function StateManager(){
this.scriptCounter = 0;
this.tempScriptQueue = new Array;
this.tempScriptCounter =0;
+ this.dialogBox = undefined;
this.displayCharacterList = {left: undefined , right: undefined , center: undefined};
this.backgroundImage = undefined;
@@ -18,6 +19,7 @@ function StateManager(){
this.defaultflagList = new Array;
this.clearAllState = function(){
+ this.dialogBox = undefined;
this.currentImage = undefined;
this.tempScreenStatus = undefined;
this.speakTextDisplayObject = undefined;
@@ -89,7 +91,6 @@ function StateManager(){
this.saveState = function(no){
var state = JSON.parse(localStorage.getItem("state"));
- console.log(self.bgm);
if(state == undefined){
state = new Array;
}
View
@@ -172,13 +172,32 @@ function vnEngine(){
case 'playVideo':
this.playVideo(script[scriptCounter-1].videoLabel);
break;
+ case 'hideGameDialog' :
+ this.hideGameDialog();
+ break;
+ case 'showGameDialog' :
+ this.showGameDialog();
+ break;
default:
alert("script error");
break;
}
}
}
+ this.showGameDialog = function(){
+ vnEngine.stateManager.dialogBox.visible = true;
+ vnEngine.stateManager.speakTextDisplayObject.visible = true;
+ vnEngine.stage.getChildAt(this.stage.getChildIndex(this.stateManager.speakTextDisplayObject)-1).visible = true;
+
+ }
+
+ this.hideGameDialog = function(){
+ vnEngine.stateManager.dialogBox.visible = false;
+ vnEngine.stateManager.speakTextDisplayObject.visible = false;
+ vnEngine.stage.getChildAt(this.stage.getChildIndex(this.stateManager.speakTextDisplayObject)-1).visible = false;
+ }
+
this.initSaveLoadMenu = function(type,isInMainMenu){
var container = new Container();
container.clickable =true;
@@ -339,7 +358,7 @@ function vnEngine(){
vnEngine.stage.removeChild(e.target.parent);
}
vnEngine.stateManager.noCheckScriptFlag = false;
- vnEngine.checkScript({type:'jumpTo', jumpLabel:'startGame'});
+ vnEngine.checkScript([{type:'jumpTo', jumpLabel:'startGame'},{type:'startGame'}]);
}
var loadButton = new Button("Load",0, y+40, this.canvas.width,30);
@@ -618,17 +637,14 @@ function vnEngine(){
this.playVideo = function(label){
var video = vnEngine.resourceManager.getResource(label);
- video.vid.setAttribute('height',vnEngine.canvas.height);
- video.vid.setAttribute('width',vnEngine.canvas.width);
- console.log(video.vid);
-
var bitmap = new Bitmap(video.vid);
+ bitmap.scaleX = vnEngine.canvas.width / video.vid.videoWidth;
+ bitmap.scaleY = vnEngine.canvas.height /video.vid.videoHeight;
vnEngine.stage.addChild(bitmap);
- video.vid.onEnded = function(){
- console.log("nyaaa");
+ video.vid.addEventListener('ended',function(){
vnEngine.stage.removeChild(bitmap);
vnEngine.checkScript();
- }
+ });
video.vid.play();
}
}
@@ -719,11 +735,30 @@ function Button(text,x,y,width,height){
function GraphicsManager(){
this.changeBackground = function(imageLabel,callback){
- vnEngine.stateManager.backgroundImage = imageLabel;
- var res = vnEngine.resourceManager.getResource(imageLabel).img;
- var bitmap = new Bitmap(res);
- bitmap.scaleY = vnEngine.canvas.height / res.height;
- bitmap.scaleX = vnEngine.canvas.width / res.width;
+ var res;
+ if(imageLabel.color == undefined){
+ vnEngine.stateManager.backgroundImage = imageLabel;
+ vnEngine.stateManager.backgroundImage = imageLabel;
+ res = vnEngine.resourceManager.getResource(imageLabel);
+ if(res == false){
+ alert("script error \nChangeBackground : \nimageLabel : "+imageLabel+" not found \nscript line : "+vnEngine.scriptCounter);
+ }
+ }
+ else res = false;
+
+ if(res){
+ res = res.img;
+ var bitmap = new Bitmap(res);
+ bitmap.scaleY = vnEngine.canvas.height / res.height;
+ bitmap.scaleX = vnEngine.canvas.width / res.width;
+ }
+ else{
+ var g = new Graphics();
+ g.beginFill(imageLabel.color);
+ g.drawRect(0,0,vnEngine.canvas.width,vnEngine.canvas.height);
+ var bitmap = new Shape(g);
+ }
+
bitmap.x =0;
bitmap.y = 0;
bitmap.isBackground = true;
@@ -826,6 +861,8 @@ function GraphicsManager(){
var shape = new Shape(textRect);
shape.onClick = vnEngine.checkNextScript;
vnEngine.stage.addChild(shape);
+ vnEngine.stateManager.dialogBox = shape;
+
if(run!=undefined){
run();
}

0 comments on commit 38cf0f4

Please sign in to comment.