view webGL/src/mainfunc.js @ 16:b322a8557f93 draft

draw text
author e105711 <yomitan.ie.u-ryukyu.ac.jp>
date Tue, 03 Jul 2012 23:20:21 +0900
parents 80789d11de5c
children 1e8fa3c370ab
line wrap: on
line source

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

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

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

function toMenu(){
    MODE = MENU;
    objsArray.length = 0;
    objsArray.push(new Obj(100,7.8125,1,"select_music"));
//    loadMusicTitle(cursor.getIndex());
//    drawText(ctx,"music_title",musicsArray(cursor.getIndex()).getTitle(),60,"white","center",432,86);
    objsArray.push(new Obj(100,40,1,"music_title"));
}

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

function toPlay(){
    MODE = PLAY;
    objsArray.length = 0;
    objsArray.push(new Obj(100,7.8125,1,"main_mode")); // main mode
    loadMusics(musicsArray[cursor.getIndex()]);
}

function toResult(){
    MODE = RESULT;
    showResult();
}

function drawObj(ctx){
    reshape(ctx);
    ctx.clearColor(0,0,0,1);
    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"]); // line
    }
    PutSpriteF(ctx,100,70,1,ctx.obj["back"]); // background
    ctx.flush();
}

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