Hello
We are starting a project(me and @nissidis )
purpose of this project is to
- get involved with c# codewriting
- develop a tile based game logic integrated within vvvv
The first task was creating a node that produces an array(spread to be exact)
where, everytime we want(ex. if the right arrow is pressed)
all the lines move down (the last line is lost)
and a new line in the top is imported.
This is the code for a 8*8 array.
- region usings
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using VVVV.PluginInterfaces.V1;
using VVVV.PluginInterfaces.V2;
using VVVV.Utils.VColor;
using VVVV.Utils.VMath;
using VVVV.Core.Logging;
- endregion usings
namespace VVVV.Nodes
{
#region PluginInfo
[PluginInfo(Name = "Array_Edit", Category = "Value", Help = "Basic template with one value in/out", Tags = "")](PluginInfo(Name = "Array_Edit", Category = "Value", Help = "Basic template with one value in/out", Tags = ""))
#endregion PluginInfo
public class ValueArray_EditNode : IPluginEvaluate
{
#region fields & pins
[Input("Input")](Input("Input"))
ISpread<double> FInput;
[Input("NewInput")](Input("NewInput"))
ISpread<double> FNewInput;
[Input("Add", IsBang = true)](Input("Add", IsBang = true))
ISpread<bool> FAdd;
[Input("GetArray", IsBang = true)](Input("GetArray", IsBang = true))
ISpread<bool> FGet;
[Output("Output")](Output("Output"))
ISpread<double> FOutput;
[Import()](Import())
ILogger FLogger;
#endregion fields & pins
public void Evaluate(int SpreadMax)
{
var FHelper = new double[SpreadMax](SpreadMax);
var Counter = new int();
Counter = SpreadMax - 8;
//8 is the number of columns in my spread
FOutput.SliceCount = SpreadMax;
if (FGet[0](0) == true)
{
for (int i = 0; i < SpreadMax; i++)
{
FHelper[i](i) = FInput[i](i);
FOutput[i](i) = FHelper[i](i);
}
}
if (FAdd[0](0) == true)
{
for (int i = 0; i < SpreadMax-8; i++)
FOutput[i](i) = FOutput[i+8](i+8);
for (int i = 0;i < 8 ; i++)
FOutput[Counter +i](Counter +i) = FNewInput[i](i);
}
}
//FLogger.Log(LogType.Debug, "hi tty!");
}
}
- How can we make the code more general(any way to find the number of columns in my spread, and not inserting it by hand)
- Any other suggestions or comments are welcome.
Next task:
Create a node which replace each number of the array with a certain texture
and ouputs a single texture(simiral to cross transform).
Code+Help (15.7 kB)