Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove Jaylib class, create Helpers to replace it #62

Open
wants to merge 3 commits into
base: 5.5
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ dependencies {
<dependency>
<groupId>uk.co.electronstudio.jaylib</groupId>
<artifactId>jaylib</artifactId>
<version>[5.0.0,5.1)</version>
<version>[5.5.0,5.6)</version>
</dependency>
</dependencies>

Expand All @@ -80,8 +80,7 @@ Download the latest `jaylib.jar` from [releases](https://github.com/electronstud
Write a demo program, e.g. Demo.java

```java
import static com.raylib.Jaylib.RAYWHITE;
import static com.raylib.Jaylib.VIOLET;
import static com.raylib.Colors.*;
import static com.raylib.Raylib.*;

public class Demo {
Expand Down Expand Up @@ -114,19 +113,19 @@ public class Demo {

Compile it:

javac -cp jaylib-5.0.0-0.jar Demo.java
javac -cp jaylib-5.5.0-0.jar Demo.java

Run it:

java -cp jaylib-5.0.0-0.jar:. Demo
java -cp jaylib-5.5.0-0.jar:. Demo

On MacOS you need this additional option:

java -XstartOnFirstThread -cp jaylib-5.0.0-0.jar:. Demo
java -XstartOnFirstThread -cp jaylib-5.5.0-0.jar:. Demo

On weirdy Windows you use semi-colons:

java -cp jaylib-5.0.0-0.jar;. Demo
java -cp jaylib-5.5.0-0.jar;. Demo

## Known issues

Expand Down
34 changes: 34 additions & 0 deletions src/com/raylib/Colors.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.raylib;

public final class Colors {
public static final Raylib.Color LIGHTGRAY = c(200, 200, 200, 255);
public static final Raylib.Color GRAY = c(130, 130, 130, 255);
public static final Raylib.Color DARKGRAY = c(80, 80, 80, 255);
public static final Raylib.Color YELLOW = c(253, 249, 0, 255);
public static final Raylib.Color GOLD = c(255, 203, 0, 255);
public static final Raylib.Color ORANGE = c(255, 161, 0, 255);
public static final Raylib.Color PINK = c(255, 109, 194, 255);
public static final Raylib.Color RED = c(230, 41, 55, 255);
public static final Raylib.Color MAROON = c(190, 33, 55, 255);
public static final Raylib.Color GREEN = c(0, 228, 48, 255);
public static final Raylib.Color LIME = c(0, 158, 47, 255);
public static final Raylib.Color DARKGREEN = c(0, 117, 44, 255);
public static final Raylib.Color SKYBLUE = c(102, 191, 255, 255);
public static final Raylib.Color BLUE = c(0, 121, 241, 255);
public static final Raylib.Color DARKBLUE = c(0, 82, 172, 255);
public static final Raylib.Color PURPLE = c(200, 122, 255, 255);
public static final Raylib.Color VIOLET = c(135, 60, 190, 255);
public static final Raylib.Color DARKPURPLE = c(112, 31, 126, 255);
public static final Raylib.Color BEIGE = c(211, 176, 131, 255);
public static final Raylib.Color BROWN = c(127, 106, 79, 255);
public static final Raylib.Color DARKBROWN = c(76, 63, 47, 255);
public static final Raylib.Color WHITE = c(255, 255, 255, 255);
public static final Raylib.Color BLACK = c(0, 0, 0, 255);
public static final Raylib.Color BLANK = c(0, 0, 0, 0);
public static final Raylib.Color MAGENTA = c(255, 0, 255, 255);
public static final Raylib.Color RAYWHITE = c(245, 245, 245, 255);

private static Raylib.Color c(int r, int g, int b, int a) {
return new Raylib.Color().r((byte) r).g((byte) g).b((byte) b).a((byte) a);
}
}
131 changes: 131 additions & 0 deletions src/com/raylib/Helpers.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
package com.raylib;

public final class Helpers {

public static Raylib.Color createColor(int r, int g, int b, int a) {
return new Raylib.Color()
.r((byte) r)
.g((byte) g)
.b((byte) b)
.a((byte) a);
}


public static Raylib.Camera3D createCamera(Raylib.Vector3 position,
Raylib.Vector3 target,
Raylib.Vector3 up,
float fovy,
int projection) {
return new Raylib.Camera3D()
._position(position)
.target(target)
.up(up)
.fovy(fovy)
.projection(projection);

}

public static Raylib.Camera2D createCamera2D(Raylib.Vector2 offset,
Raylib.Vector2 target,
float rotation,
float zoom) {
return new Raylib.Camera2D()
.offset(offset)
.target(target)
.rotation(rotation)
.zoom(zoom);
}


public Raylib.Rectangle createRectangle(float x, float y, float width, float height) {
return new Raylib.Rectangle()
.x(x)
.y(y)
.width(width)
.height(height);
}

public static Raylib.Rectangle createRectangle(Raylib.Rectangle rect) {
return new Raylib.Rectangle()
.x(rect.x())
.y(rect.y())
.width(rect.width())
.height(rect.height());
}


public static Raylib.BoundingBox createBoundingBox(Raylib.Vector3 min, Raylib.Vector3 max) {
return new Raylib.BoundingBox()
.min(min)
.max(max);
}

public static Raylib.BoundingBox createBoundingBox(Raylib.BoundingBox bb) {
return new Raylib.BoundingBox()
.min(bb.min())
.max(bb.max());
}


public static Raylib.Ray createRay(Raylib.Vector3 position, Raylib.Vector3 direction) {
return new Raylib.Ray()
._position(position)
.direction(direction);
}

public static Raylib.Ray createRay(Raylib.Ray ray) {
return new Raylib.Ray()
._position(ray._position())
.direction(ray.direction());
}


public static Raylib.RayCollision createRayCollision(boolean hit,
float distance,
Raylib.Vector3 point,
Raylib.Vector3 normal) {
return new Raylib.RayCollision()
.hit(hit)
.distance(distance)
.point(point)
.normal(normal);
}

public static Raylib.RayCollision createRayCollision(Raylib.RayCollision rc) {
return new Raylib.RayCollision()
.hit(rc.hit())
.distance(rc.distance())
.point(rc.point())
.normal(rc.normal());
}


public static Raylib.Vector3 createVector3(float x, float y, float z) {
return new Raylib.Vector3()
.x(x)
.y(y)
.z(z);
}

public static Raylib.Vector3 createVector3(Raylib.Vector3 vector3) {
return new Raylib.Vector3()
.x(vector3.x())
.y(vector3.y())
.z(vector3.z());
}


public static Raylib.Vector2 createVector2(float x, float y) {
return new Raylib.Vector2()
.x(x)
.y(y);
}

public static Raylib.Vector2 createVector2(Raylib.Vector2 vector2) {
return new Raylib.Vector2()
.x(vector2.x())
.y(vector2.y());
}


}
158 changes: 0 additions & 158 deletions src/com/raylib/Jaylib.java

This file was deleted.

Loading