view webGL/src/mainfunc.js @ 22:df7f7eef72ef draft

put canvas to center
author e105711 <yomitan.ie.u-ryukyu.ac.jp>
date Sun, 15 Jul 2012 00:45:56 +0900
parents 5da2afa45e41
children
line wrap: on
line source

function gameRender(ctx){
    drawObj(ctx);
}

function gameUpdate(){
    switch(MODE){
    case PLAY:
	playUpdate();
	break;
    default:
	break;
    }    
}

function toTitle(){
    MODE = TITLE;
    resetResult();
    objsArray.length = 0;
    objsArray.push(new Obj(100,30,1,"title"));
    objsArray.push(new Obj(100,90,1,"press"));
}

function toMenu(){
    MODE = MENU;
    resetResult();
    objsArray.length = 0;
    objsArray.push(new Obj(100,7.8125,1,"select_music"));
    loadMusicTitle(cursor.getIndex());
    objsArray.push(new Obj(100,40,1,"music_title"));
}

function toMain(){
    MODE = MAIN;
    resetResult();
    objsArray.length = 0;
    objsArray.push(new Obj(100,7.8125,1,"main_mode"));
    objsArray.push(new Obj(100,105,1,"line"));
}

function toPlay(){
    MODE = PLAY;
    resetResult(ctx);
    objsArray.length = 0;
    objsArray.push(new Obj(100,7.8125,1,"main_mode"));
    objsArray.push(new Obj(100,40,1,"judge"));
    dummyPlay();
    loadMusics(musicsArray[cursor.getIndex()]);
}

function toResult(){
    objsArray.length = 0;
    objsArray.push(new Obj(100,7.8125,1,"result_title"));
    MODE = RESULT;
    showResult();
}

function drawObj(ctx){
    reshape(ctx);
    ctx.clear(ctx.COLOR_BUFFER_BIT | ctx.DEPTH_BUFFER_BIT);
    for(var i=0;i < objsArray.length;i++){
	var obj = objsArray[i];
	PutSpriteF(ctx,obj.x,obj.y,obj.scale,ctx.obj[obj.imgName]);
    }
    if(MODE==PLAY){
	drawNote(ctx);
	PutSpriteF(ctx,100,105,1,ctx.obj["line"]);
	drawBeam(ctx);
    }
    PutSpriteF(ctx,100,70,1,ctx.obj["back"]);
    ctx.flush();
}

function playUpdate(){
    updateNote();
    if(BGMEndCheck()){
	toResult();
    }
}