read a .we minetest schema
- use ground has maze walls
This commit is contained in:
71
java/org/artisanlogiciel/games/minetest/Range.java
Normal file
71
java/org/artisanlogiciel/games/minetest/Range.java
Normal file
@@ -0,0 +1,71 @@
|
||||
package org.artisanlogiciel.games.minetest;
|
||||
|
||||
public class Range {
|
||||
int min;
|
||||
int max;
|
||||
|
||||
public int getMin() {
|
||||
return min;
|
||||
}
|
||||
|
||||
public int getMax() {
|
||||
return max;
|
||||
}
|
||||
|
||||
public Range()
|
||||
{
|
||||
// invalid range, means empty interval
|
||||
min = 0;
|
||||
max = -1;
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return ( min > max );
|
||||
}
|
||||
|
||||
boolean union(Range other)
|
||||
{
|
||||
boolean update = false;
|
||||
if ( ! other.isEmpty()) {
|
||||
update = updateBounds(other.getMin()) | updateBounds(other.getMax());
|
||||
}
|
||||
return update;
|
||||
}
|
||||
|
||||
boolean updateBounds(int v)
|
||||
{
|
||||
boolean update = false;
|
||||
|
||||
// special case where previous range was unset ( min > max ).
|
||||
if ( isEmpty() )
|
||||
{
|
||||
min = v;
|
||||
max = v;
|
||||
return true;
|
||||
}
|
||||
if ( v < min )
|
||||
{
|
||||
update = true;
|
||||
min = v;
|
||||
}
|
||||
if ( v > max )
|
||||
{
|
||||
update = true;
|
||||
max = v;
|
||||
}
|
||||
return update;
|
||||
}
|
||||
|
||||
|
||||
public int getRangeSize() {
|
||||
if (isEmpty())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return max - min;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user