本文整理匯總了TypeScript中gamejs.image.load方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript image.load方法的具體用法?TypeScript image.load怎麽用?TypeScript image.load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gamejs.image
的用法示例。
在下文中一共展示了image.load方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: generateBuilding
export function generateBuilding(){
var building=[];
var sky=gamejs.image.load("img/SKY.JPG");
sky.position=new gamejs.Rect([0,0]);
building.push(sky);
for(var j=0;j<4 /*42*/;j++){
var floor=50+(j*100);
var pasillo=new gamejs.graphics.Surface([600,100]);
if(j % 2==0)
pasillo.fill("orangered");
else
pasillo.fill("white");
pasillo.position=new gamejs.Rect([20,floor]);
building.push(pasillo);
generateDoors(floor,building);
}
var elevator=new gamejs.graphics.Surface([40,480]);
elevator.fill("blue");
elevator.position=new gamejs.Rect([(3*125)-(125/2),0]);
building.push(elevator);
return building;
}
示例2: generateDoors
export function generateDoors(floor,building){
for(var i=0;i<4;i++)
{
var rnd=utils.getRandomInt(1,5);
var door=new gamejs.graphics.Surface([35,70]);
if(rnd===1)
{
door=gamejs.image.load("img/PointDoor.png");
door.type="PointDoor";
door.points=utils.getRandomInt(1,1001);
}else{
door=gamejs.image.load("img/Door.png");
door.type="BasicDoor";
door.points=0;
}
door.position=new gamejs.Rect([(i+1)*125,floor+30]);
building.push(door);
}
}
示例3: function
gamejs.ready(function(){
window.addEventListener("contextmenu",function(e){
e.stopPropagation();
e.preventDefault();
});
gamejs.display.setCaption("Torre Utopia");
var display=gamejs.display.setMode([640,480]);
//var sky=new gamejs.graphics.Surface([640,480]);
//sky.fill("cyan");
/* Generating world */
var building: any=generation.generateBuilding();
var people=[];
var bullets=[];
var elevation={render: function(ms){
return false;
}};
remaining=building.filter(function(val){
return (val.type=="PointDoor");
}).length;
var hud=new gamejs.graphics.Surface([600,50]);
hud.fill("white");
hud.renderScore=function(score){
hud.clear(hud.getRect());
var font=new gamejs.font.Font("30px P2P");
hud.blit(font.render(score));
};
var mastin=new gamejs.graphics.Surface([25,40]);
mastin.fill("green");
mastin=gamejs.image.load("img/Mastin.png");
mastin.position=new gamejs.Rect([50,250-40]);
mastin.move={};
var elevator=gamejs.image.load("img/Elevator.png");
elevator.type="Elevator";
elevator.position=new gamejs.Rect([(3*125)-(125/2),250-100]);
building.push(elevator);
gamejs.event.onEvent(function(event){
if(event.type===gamejs.event.KEY_DOWN)
{
if(event.key===gamejs.event.K_LEFT)
mastin.move.left=true;
if(event.key===gamejs.event.K_RIGHT)
mastin.move.right=true;
if(event.key===gamejs.event.K_UP)
mastin.move.up=true;
if(event.key===gamejs.event.K_DOWN)
mastin.move.down=true;
if(event.key===gamejs.event.K_SPACE)
mastin.move.jump=true;
mastin.move.animation=true;
if(!state.started)
state.started=true;
if(state.gameOver && !state.waiting)
window.location.reload();
}
if(event.type===gamejs.event.KEY_UP)
{
if(event.key===gamejs.event.K_LEFT)
mastin.move.left=false;
if(event.key===gamejs.event.K_RIGHT)
mastin.move.right=false;
if(event.key===gamejs.event.K_UP)
mastin.move.up=false;
if(event.key===gamejs.event.K_DOWN)
mastin.move.down=false;
if(event.key===gamejs.event.K_SPACE)
mastin.move.jump=false;
mastin.move.animation=false;
}
if(event.type===gamejs.event.TOUCH_DOWN)
{
var x=event.touches[0].pos[0];
var y=event.touches[0].pos[1];
if(x<window.innerWidth/2)
mastin.move.left=true;
if(x>window.innerWidth/2)
mastin.move.right=true;
if(y<window.innerHeight/4)
mastin.move.up=true;
if(y>(window.innerHeight*3/4))
mastin.move.down=true;
if(!state.started)
state.started=true;
if(state.gameOver && !state.waiting)
window.location.reload();
}
if(event.type===gamejs.event.TOUCH_UP)
{
var x=event.touches[0].pos[0];
var y=event.touches[0].pos[1];
mastin.move.left=false;
//.........這裏部分代碼省略.........
示例4: return
gamejs.onTick(function(ms){
display.clear();
if(state.started)
{
//LOGIC
if(remaining==0)
{
building=building.filter(function(val){
return (val.type!="BasicDoor" && val.type!="PointDoor" && val.type!="OldPointDoor" && val.type!="PointsText");
});
//REGENERATE DOORS
for(var j=0;j<4;j++)
{
var floor=50+(j*100);
generation.generateDoors(floor,building);
}
remaining=building.filter(function(val){
return (val.type=="PointDoor");
}).length;
//PUT LEVEL UP
//DELETE MALOS
//INCREMENT MALOS DIFFICULT
}
if(mastin.move.up && state.moveEnabled)
{
//CHECK INTERACTIVE ELEMENTS
for(var index=0;index<building.length;index++){
var door=building[index];
if(door.type != undefined && door.type == "PointDoor")
{
if(utils.checkCollision(mastin,door))
{
sfx.door.play();
remaining--;
door.fill("cyan");
door.type = "OldPointDoor";
score+=door.points;
hud.renderScore(score);
building=building.filter(function(value,idx,array){
return (idx!=index);
});
building.push(door);
var points=utils.textToSurface(door.points+"");
points.type="PointsText";
points.position=new gamejs.Rect([door.position.x,door.position.y]);
building.push(points);
}
}
elevation=machines.elevator(mastin,door,elevator,state,-1,elevation,sfx);
}
}
if(mastin.move.down && state.moveEnabled)
{
for(var index=0;index<building.length;index++){
var door=building[index];
elevation=machines.elevator(mastin,door,elevator,state,1,elevation,sfx);
}
}
//GENERATE 'MALOS'
if(utils.getRandomInt(1,501)==1)
{
var doors=building.filter(function(value){
return (value.type=="PointDoor" || value.type=="BasicDoor");
});
var index=utils.getRandomInt(0,doors.length);
var malo=new gamejs.graphics.Surface([25,40]);
malo.fill("yellow");
malo=gamejs.image.load("img/Malo.png");
malo.position=new gamejs.Rect([doors[index].position.x,doors[index].position.y+30]);
malo.time=0;
people.push(malo);
}
people.forEach(function(malo){
malo.time++;
var sentido;
if(mastin.position.x < malo.position.x){
if(!utils.checkCollision(mastin,malo))
{
var maloCollision=false;
people.forEach(function(segundoMalo){
if(utils.checkCollision(malo,segundoMalo))
maloCollision=true;
});
if(!maloCollision)
malo.position.moveIp(-0.2*ms,0);
}
sentido=-1;
}
if(mastin.position.x > malo.position.x){
if(!utils.checkCollision(mastin,malo))
{
var maloCollision=false;
people.forEach(function(segundoMalo){
if(utils.checkCollision(malo,segundoMalo))
maloCollision=true;
});
if(!maloCollision)
//.........這裏部分代碼省略.........