forked from Mirrors/openclonk
maze: fix warning for declaration of variables and move spray can to Decoration.ocd
parent
6ac777e705
commit
d3bc20f168
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]);
|
||||
|
@ -39,7 +44,7 @@ public func HoldingEnabled() { return true; }
|
|||
public func ControlUseHolding(object clonk, int new_x, int new_y)
|
||||
{
|
||||
// Out of reach? Stop spraying.
|
||||
if (Distance(0,0,new_x,new_y) > max_dist)
|
||||
if (Distance(0, 0, new_x, new_y) > max_dist)
|
||||
{
|
||||
SetAction("Idle");
|
||||
return true;
|
||||
|
@ -49,16 +54,22 @@ 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; }
|
||||
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);
|
||||
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;
|
||||
}
|
||||
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;
|
||||
return true;
|
||||
|
@ -80,14 +91,25 @@ private func StartSpraying(object clonk, int x, int y)
|
|||
{
|
||||
// Go into spray mode and place an initial blob
|
||||
last_x = x; last_y = y;
|
||||
last_ldx=last_ldy=0;
|
||||
last_ldx = last_ldy = 0;
|
||||
var r = Random(90), wdt = 2;
|
||||
var ldx = Sin(r, wdt), ldy = Cos(r, wdt);
|
||||
DrawMaterialQuad(paint_col, x-ldx,y-ldy, x-ldy,y+ldx, x+ldx,y+ldy, x+ldy,y-ldx, DMQ_Bridge);
|
||||
DrawMaterialQuad(paint_col, x - ldx, y - ldy, x - ldy, y + ldx, x + ldx, y + ldy, x + ldy, y - ldx, DMQ_Bridge);
|
||||
SetAction("Spraying");
|
||||
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