forked from Mirrors/openclonk
maze: fix warning for declaration of variables and move spray can to Decoration.ocd
parent
22ca0513cc
commit
3a866caa73
Before Width: | Height: | Size: 203 B After Width: | Height: | Size: 203 B |
|
@ -1,4 +1,9 @@
|
|||
/* Spray can */
|
||||
/**
|
||||
Spray can
|
||||
Let out the little artist in you!
|
||||
|
||||
@author Sven2
|
||||
*/
|
||||
|
||||
local last_x, last_y, last_ldx, last_ldy;
|
||||
local paint_col;
|
||||
|
@ -6,13 +11,13 @@ local max_dist = 50;
|
|||
|
||||
static SprayCan_last_col;
|
||||
|
||||
protected func Construction()
|
||||
public func Construction()
|
||||
{
|
||||
SetPaintCol(SprayCan_last_col++);
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
func SetPaintCol(int idx)
|
||||
public func SetPaintCol(int idx)
|
||||
{
|
||||
idx %= 5;
|
||||
var tex_name = Format("Paint%s",["Red", "Green", "Teal", "Yellow", "White"][idx]);
|
||||
|
@ -49,15 +54,21 @@ public func ControlUseHolding(object clonk, int new_x, int new_y)
|
|||
new_x += GetX(); new_y += GetY();
|
||||
|
||||
// (re-)start spraying
|
||||
if (GetAction() != "Spraying") StartSpraying(clonk, new_x, new_y);
|
||||
if (GetAction() != "Spraying")
|
||||
StartSpraying(clonk, new_x, new_y);
|
||||
|
||||
// Spray paint if position moved
|
||||
if (new_x==last_x && new_y == last_y) return true;
|
||||
if (new_x == last_x && new_y == last_y)
|
||||
return true;
|
||||
var wdt = 2;
|
||||
var dx = new_x - last_x, dy = new_y - last_y;
|
||||
var d = Distance(dx, dy);
|
||||
var ldx = dy * wdt / d, ldy = -dx *wdt / d;
|
||||
if (!last_ldx && !last_ldy) { last_ldx=ldx; last_ldy=ldy; }
|
||||
if (!last_ldx && !last_ldy)
|
||||
{
|
||||
last_ldx = ldx;
|
||||
last_ldy = ldy;
|
||||
}
|
||||
DrawMaterialQuad(paint_col, last_x - last_ldx, last_y - last_ldy, last_x + last_ldx, last_y + last_ldy, new_x + ldx, new_y + ldy, new_x - ldx, new_y - ldy, DMQ_Bridge);
|
||||
last_x = new_x; last_y = new_y;
|
||||
last_ldx = ldx; last_ldy = ldy;
|
||||
|
@ -88,6 +99,17 @@ private func StartSpraying(object clonk, int x, int y)
|
|||
return true;
|
||||
}
|
||||
|
||||
public func Definition(def)
|
||||
{
|
||||
SetProperty("PictureTransformation", Trans_Rotate(-30, 0, 1, 1), def);
|
||||
}
|
||||
|
||||
|
||||
/*-- Properties --*/
|
||||
|
||||
local Collectible = true;
|
||||
local Name = "$Name$";
|
||||
local Description = "$Description$";
|
||||
|
||||
local ActMap = {
|
||||
Spraying = {
|
||||
|
@ -96,15 +118,7 @@ local ActMap = {
|
|||
Length = 1,
|
||||
Delay = 1,
|
||||
Name = "Spraying",
|
||||
Sound = "SprayCan::SprayCan",
|
||||
Sound = "Objects::SprayCan",
|
||||
NextAction = "Spraying",
|
||||
}
|
||||
};
|
||||
|
||||
func Definition(def) {
|
||||
SetProperty("PictureTransformation",Trans_Rotate(-30,0,1,1),def);
|
||||
}
|
||||
|
||||
local Collectible = 1;
|
||||
local Name = "$Name$";
|
||||
local Description = "$Description$";
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
|
@ -10,6 +10,7 @@ Goals=Goal_RubyHunt=1;
|
|||
|
||||
[Definitions]
|
||||
Definition1=Objects.ocd
|
||||
Definition2=Decoration.ocd/Misc.ocd/SprayCan.ocd
|
||||
|
||||
[Player1]
|
||||
Crew=Clonk=1
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
Dynamic maze
|
||||
--*/
|
||||
|
||||
static g_caves, g_end_cave_x, g_end_cave_y;
|
||||
local goal_cave;
|
||||
|
||||
func InitializePlayer(int plr)
|
||||
|
|
Loading…
Reference in New Issue