New idea: Rogulike randomiser for potion, etc., variable jump height controlled by key pressing time

Former-commit-id: 2408607006af5f29d8ecbd3ced655f2908c97afb
Former-commit-id: 33f03178aa8af54f76ce3b1324b2134173a540ff
This commit is contained in:
Song Minjae
2016-02-24 02:58:25 +09:00
parent 34a04943ab
commit 0b6d8ff44d
13 changed files with 86 additions and 41 deletions

View File

@@ -44,9 +44,7 @@ public class PBFSigrid {
p.actorValue.set("accel", Player.WALK_ACCEL_BASE);
p.actorValue.set("accelmult", 1.0f);
p.actorValue.set("jumppower", 6.5f);
// in frames
p.actorValue.set("jumplength", 30f);
p.actorValue.set("jumppower", 5f);
p.actorValue.set("basemass", 80f);

View File

@@ -3,8 +3,6 @@ package com.Torvald.Terrarum.Actors;
import com.Torvald.Terrarum.Actors.Faction.Faction;
import com.Torvald.Terrarum.GameControl.EnumKeyFunc;
import com.Torvald.Terrarum.GameControl.KeyMap;
import com.Torvald.Terrarum.MapDrawer.LightmapRenderer;
import com.Torvald.Terrarum.MapDrawer.MapCamera;
import com.Torvald.Terrarum.MapDrawer.MapDrawer;
import com.Torvald.Terrarum.Terrarum;
import com.Torvald.spriteAnimation.SpriteAnimation;
@@ -15,7 +13,6 @@ import org.lwjgl.input.Controller;
import org.lwjgl.input.Controllers;
import org.newdawn.slick.*;
import java.io.Serializable;
import java.util.HashSet;
/**
@@ -25,8 +22,13 @@ public class Player extends ActorWithBody implements Controllable, Pocketed, Fac
@Nullable public Controllable vehicleRiding;
int jumpPowerCounter = 0;
int jumpCounter = 0;
int walkPowerCounter = 0;
private final int MAX_JUMP_LENGTH = 20;
/**
* experimental value.
*/
private final float JUMP_ACCELERATION_MOD = 92f / 10000f;
private final int WALK_FRAMES_TO_MAX_ACCEL = 6;
public float readonly_totalX = 0, readonly_totalY = 0;
@@ -402,8 +404,8 @@ public class Player extends ActorWithBody implements Controllable, Pocketed, Fac
if (!noClip) {
if (super.isGrounded()) {
jumping = true;
jump();
}
jump();
}
else {
walkVertical(true, AXIS_POSMAX);
@@ -411,7 +413,7 @@ public class Player extends ActorWithBody implements Controllable, Pocketed, Fac
}
else {
jumping = false;
jumpPowerCounter = 0;
jumpCounter = 0;
}
}
@@ -420,43 +422,43 @@ public class Player extends ActorWithBody implements Controllable, Pocketed, Fac
}
/**
* See ./work_files/Jump\ power\ by\ pressing\ time.gcx
*/
private void jump() {
float len = actorValue.getAsFloat("jumplength");
float pwr = actorValue.getAsFloat("jumppower");
if (jumping) {
float len = MAX_JUMP_LENGTH;
float pwr = actorValue.getAsFloat("jumppower");
//if (jumping) {
// // Limit increment of jumpPowerCounter
// if (jumpPowerCounter < len) {
// jumpPowerCounter += 1;
//
// /**
// * Limit jumping
// */
// //super.veloY = jumpFuncSqu(pwr, len);
// super.veloY += jumpFuncLin(pwr, len);
// //super.veloY = jumpFuncExp(pwr, len);
//
// System.out.println(jumpFuncLin(pwr, len));
// }
//
// super.grounded = false;
//}
// increment jump counter
if (jumpCounter < len) jumpCounter += 1;
// At least this works, though. Useful if it were AI-controlled.
super.setVeloY(super.getVeloY()
-
pwr * FastMath.sqrt(super.getScale())
);
float sumT = (jumpCounter * (jumpCounter + 1)) / 2f;
float timedJumpCharge = ((len + 1) / 2f) - (sumT / len);
if (timedJumpCharge < 0) timedJumpCharge = 0;
float jumpAcc = pwr * timedJumpCharge * JUMP_ACCELERATION_MOD;
super.setVeloY(super.getVeloY()
- jumpAcc
);
}
// for mob AI:
//super.setVeloY(super.getVeloY()
// -
// pwr * FastMath.sqrt(super.getScale())
//);
}
private float jumpFuncLin(float pwr, float len) {
return -(pwr / len) * jumpPowerCounter;
return -(pwr / len) * jumpCounter;
}
private float jumpFuncSqu(float pwr, float len) {
return (pwr / (len * len))
* (jumpPowerCounter - len)
* (jumpPowerCounter - len) // square
* (jumpCounter - len)
* (jumpCounter - len) // square
- pwr;
}

View File

@@ -36,4 +36,10 @@ Topaz -> R·G·B -> Diamond·Amethyst
* Colouring
Natural: Use 4096
Magical/Surreal: Use 24 Bits
Magical/Surreal: Use 24 Bits
= Colouring of potion
- Randomised, roguelike fashion
- Choose Col(R40, G40, B40) from set of finite cards:
39, 39, 19, 19, 0, 0
- MULTIPLY blend chosen colour with white texture

View File

@@ -35,7 +35,7 @@ public class MapGenerator {
private static int SHORE_WIDTH = 120;
private static int MAX_OCEAN_DEPTH = 200;
private static final int TERRAIN_PERTURB_OFFSETMAX = 32; // [-val , val]
private static final int TERRAIN_PERTURB_OFFSETMAX = 0; // [-val , val]
private static final int TERRAIN_PERTURB_LARGESTFEATURE = 256;
private static final float TERRAIN_PERTURB_RATE = 0.5f;

View File

@@ -0,0 +1,33 @@
package com.Torvald.Terrarum;
import com.Torvald.ColourUtil.Col4096;
import java.util.ArrayList;
import java.util.Hashtable;
/**
* Created by minjaesong on 16-02-23.
*/
public class RoguelikeRandomiser {
private static final int[] POTION_PRIMARY_COLSET = {15, 15, 8, 8, 0, 0};
private static Hashtable<Integer, Col4096> potionColours;
private static ArrayList<Col4096> coloursTaken;
private static final int POTION_HEAL_TIER1 = 0x00;
private static final int POTION_HEAL_TIRE2 = 0x01;
private static final int POTION_MAGIC_REGEN_TIER1 = 0x10;
private static final int POTION_BERSERK_TIER1 = 0x20;
public RoguelikeRandomiser() {
potionColours = new Hashtable<>();
coloursTaken = new ArrayList<>();
}
}