хмм
This commit is contained in:
parent
7eaccacc68
commit
b21bd50e7b
@ -13,6 +13,7 @@ import java.io.ByteArrayInputStream
|
||||
import java.io.DataInputStream
|
||||
import java.io.File
|
||||
import java.util.zip.Inflater
|
||||
import kotlin.random.Random
|
||||
|
||||
private val LOGGER = LogManager.getLogger()
|
||||
|
||||
@ -162,11 +163,15 @@ fun main() {
|
||||
|
||||
//client.world!!.parallax = Starbound.parallaxAccess["garden"]
|
||||
|
||||
for (i in 0 .. 16) {
|
||||
val item = ItemEntity(client.world!!, Starbound.ITEM["money"]!!)
|
||||
val item = Starbound.ITEM.values.random()
|
||||
val rand = java.util.Random()
|
||||
|
||||
for (i in 0 .. 240) {
|
||||
val item = ItemEntity(client.world!!, item)
|
||||
|
||||
item.position = Vector2d(600.0 + 16.0 + i, 721.0 + 48.0)
|
||||
item.spawn()
|
||||
item.movement.applyVelocity(Vector2d(rand.nextDouble() * 1000.0 - 500.0, rand.nextDouble() * 1000.0 - 500.0))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ class ItemEntity(world: World<*, *>, val def: IItemDefinition) : Entity(world) {
|
||||
|
||||
// все предметы в мире являются коробками
|
||||
val fixture = FixtureDef(
|
||||
shape = PolygonShape().also { it.setAsBox(1.0, 1.0) },
|
||||
shape = PolygonShape().also { it.setAsBox(0.75, 0.75) },
|
||||
restitution = 0.0,
|
||||
friction = 1.0,
|
||||
density = 0.3,
|
||||
|
@ -63,6 +63,12 @@ abstract class MovementController<T : IEntity>(val entity: T) : IContactListener
|
||||
|
||||
open val velocity get() = body.linearVelocity
|
||||
|
||||
open fun applyVelocity(velocity: Vector2d) {
|
||||
if (velocity != Vector2d.ZERO) {
|
||||
body.applyLinearImpulseToCenter(velocity)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверяет, находится ли что-либо под нами
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user