あれのベータのサンプル学習メモ

ベータのサンプルをコピペ用にメモ
(ベータなので仕様変更があるかもしれないのであまりかかない)

テンプレのプラットフォームサンプルを読み込んだ。
roomのタイル情報を読み込んで、オブジェクト毎のあたり判定をチェックしている方式を使っていた。

oGameオブジェクト
create
map = layer_tilemap_get_id("Collisions"); // コリジョンレイヤのタイルマップ情報を読み込む
hills = layer_get_all_elements("Hills");  Hillアセットレイアのアセット情報を読み込む。

switch(room){ ルームによりスプライトを置き換えていくコード。
 case rSand: // if we are in the sand room
  for(i=0;i<array_length_1d(hills);i++){
   if(layer_sprite_get_sprite(hills[i]) == sBGHills_grass){ 
   layer_sprite_change(hills[i],sBGHills_sand);

step
アセットを移動する

layer_sprite_x(clouds[i], layer_sprite_get_x(clouds[i])+1);
if(layer_sprite_get_x(clouds[i]) > room_width){ 画面外だったら左端に横幅分左に移動
layer_sprite_x(clouds[i],-sprite_get_width(layer_sprite_get_sprite(clouds[i])));

draw
draw_sprite(sPickupStar,0,view_wport[0]-50,50); 
draw_text(view_wport[0]-20-sprite_get_width(sPickupStar),57,score);

//-------------------------------------------------------------
oPlayer
create
カメラフォロー
view_camera[0] = camera_create_view(x-500,y-200,1000,400,0,oPlayer,-1,-1,100,100);
step(scrProcessPlayer)
足元のタイルを3点調べる。tileのtCollision
c1 = tilemap_get_at_pixel(oGame.map,x-(sprite_get_width(sprite_index)/2),y); 
c2 = tilemap_get_at_pixel(oGame.map,x+(sprite_get_width(sprite_index)/2),y); 
c3 = tilemap_get_at_pixel(oGame.map,x,y); 

y = real(y&$ffffffc0);タイルの上に移動?8進数
if( y&$3f>0 )?
----------------------------------
oGhostを参考にテストをしてみたい。

stepーscript

var xx,yy,c1,c2; // temp var only for use in this script

hspd = dir * spd; // find out how far the object has moved
x+=hspd; // apply the distance to the object

if(dir == -1){ // if moving left
image_index = 1; // set the sprite to point the correct way
c1 = -1; // reset the collision tile checkers
c2 = -1;
c1 = tilemap_get_at_pixel(oGame.map, x, y); // check the left edge of the sprite
c2 = tilemap_get_at_pixel(oGame.map,x,y+sprite_height); // check below the left edge of the sprite, since ghosts dont like heights
if*1{ // if there is something blocking the left or if there would be a fall to the left
x = (x&$ffffffc0)+sprite_width; // move the object to the edge of the tile
dir *= -1; // change the direction
}
}else if(dir == 1) // if moving right
{ // Otherwise, check collision to the right
image_index = 0; // set the sprite to point the correct way
c1 = -1 // reset the collision tile checkers
c2 = -1;
c1 = tilemap_get_at_pixel(oGame.map,x+sprite_width,y); // check the right edge of the sprite
c2 = tilemap_get_at_pixel(oGame.map,x+sprite_width,y+sprite_height); // check below the right edge of the sprite, since ghosts dont like heights
if*2{ // if there is something blocking the right or if there would be a fall to the right
x = (x&$ffffffc0); // move the object to the edge of the tile || $ffffffc0 rounds the position to the nearest 64
dir *= -1; // change the direction
}
}

 -------------------------------------

 daruinode text script

///(x,y,text,hspeed,vspeed,color,destroytime)

var textobject = instance_create_layer(argument0,argument1,"Text_Layer",obj_Text);
textobject.text = argument2;
textobject.hspeed = argument3;
textobject.vspeed = argument4;
textobject.textcolor = argument5;
textobject.alarm[0] = room_speed*argument6;

 

*1:c1 >= 1) || (c2 <= 0

*2:c1 >= 1) || (c2 <= 0