work on dungeon demo

This commit is contained in:
Alexander Klingenbeck 2023-06-13 23:03:38 +02:00
parent a7cf7b76ed
commit f3bdc08f2c
264 changed files with 2752 additions and 28 deletions

View File

@ -81,7 +81,13 @@ function main(){
returnType: "void",
params: [{type: "Shader *",name:"shader"},{type:"int",name:"shaderConstant"},{type:"int",name:"location"}]
})
api.functions.push({
name: "ImageReadPixel",
description: "Read a single pixel from an image",
returnType: "Color",
params: [{type: "Image *",name:"image"},{type:"int",name:"x"},{type:"int",name:"y"}]
})
// Define a new header
const core = new RayLibHeader("raylib_core")
core.includes.include("raymath.h")
@ -541,8 +547,8 @@ function main(){
ignore("Vector3ToFloatV")
ignore("MatrixToFloatV")
ignore("QuaternionToAxisAngle")
core.exportGlobalConstant("DEG2RAD", "(PI/180.0)")
core.exportGlobalConstant("RAD2DEG", "(180.0/PI)")
core.exportGlobalDouble("DEG2RAD", "(PI/180.0)")
core.exportGlobalDouble("RAD2DEG", "(180.0/PI)")
const setOutParam = (fun: RayLibFunction, index: number) => {
const param = fun!.params![index]
@ -632,8 +638,8 @@ function main(){
core.exportGlobalStruct("Color", x.name, x.values, x.description)
})
api.enums.forEach(x => core.addEnum(x))
core.exportGlobalConstant("MATERIAL_MAP_DIFFUSE", "Albedo material (same as: MATERIAL_MAP_DIFFUSE")
core.exportGlobalConstant("MATERIAL_MAP_SPECULAR", "Metalness material (same as: MATERIAL_MAP_SPECULAR)")
core.exportGlobalInt("MATERIAL_MAP_DIFFUSE", "Albedo material (same as: MATERIAL_MAP_DIFFUSE")
core.exportGlobalInt("MATERIAL_MAP_SPECULAR", "Metalness material (same as: MATERIAL_MAP_SPECULAR)")
core.writeTo("src/bindings/js_raylib_core.h")
core.typings.writeTo("examples/lib.raylib.d.ts")
const ignored = api.functions.filter(x => x.binding?.ignore).length

View File

@ -65,7 +65,7 @@ export class RayLibHeader extends QuickJsHeader {
addEnum(renum: RayLibEnum){
console.log("Binding enum "+ renum.name)
renum.values.forEach(x => this.exportGlobalConstant(x.name, x.description))
renum.values.forEach(x => this.exportGlobalInt(x.name, x.description))
}
addApiStruct(struct: RayLibStruct){
@ -118,9 +118,15 @@ export class RayLibHeader extends QuickJsHeader {
this.typings.constants.tsDeclareConstant(exportName, structName, description)
}
exportGlobalConstant(name: string, description: string){
exportGlobalInt(name: string, description: string){
this.moduleInit.statement(`JS_SetModuleExport(ctx, m, "${name}", JS_NewInt32(ctx, ${name}))`)
this.moduleEntry.statement(`JS_AddModuleExport(ctx, m, "${name}")`)
this.typings.constants.tsDeclareConstant(name, "number", description)
}
exportGlobalDouble(name: string, description: string){
this.moduleInit.statement(`JS_SetModuleExport(ctx, m, "${name}", JS_NewFloat64(ctx, ${name}))`)
this.moduleEntry.statement(`JS_AddModuleExport(ctx, m, "${name}")`)
this.typings.constants.tsDeclareConstant(name, "number", description)
}
}

View File

@ -1620,6 +1620,8 @@ declare function easeElasticIn(t: number, b: number, c: number, d: number): numb
declare function setModelMaterial(model: Model, materialIndex: number, material: Material): void;
/** Set shader constant in shader locations array */
declare function setShaderLocation(shader: Shader, shaderConstant: number, location: number): void;
/** Read a single pixel from an image */
declare function imageReadPixel(image: Image, x: number, y: number): Color;
/** (PI/180.0) */
declare var DEG2RAD: number;
/** (180.0/PI) */

View File

@ -29,7 +29,7 @@ let image = loadImage("resources/cubicmap.png"); // Load cubicmap image (RA
let cubicmap = loadTextureFromImage(image); // Convert image to texture to display (VRAM)
const mesh = genMeshCubicmap(image, new Vector3(1.0, 1.0, 1.0));
const model = loadModelFromMesh(mesh);
const floor = loadModelFromMesh(mesh);
// NOTE: By default each cube is mapped to one part of texture atlas
let texture = loadTexture("resources/cubicmap_atlas.png"); // Load map texture
@ -37,7 +37,7 @@ let texture = loadTexture("resources/cubicmap_atlas.png"); // Load map textur
//model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
const mat = loadMaterialDefault()
setMaterialTexture(mat, MATERIAL_MAP_DIFFUSE, texture)
setModelMaterial(model,0,mat)
setModelMaterial(floor,0,mat)
const mapPosition = new Vector3(-16.0, 0.0, -8.0); // Set model position
@ -62,7 +62,7 @@ while (!windowShouldClose()) // Detect window close button or ESC key
beginMode3D(camera);
drawModel(model, mapPosition, 1.0, WHITE);
drawModel(floor, mapPosition, 1.0, WHITE);
endMode3D();
@ -82,7 +82,7 @@ while (!windowShouldClose()) // Detect window close button or ESC key
//--------------------------------------------------------------------------------------
unloadTexture(cubicmap);
unloadTexture(texture);
unloadModel(model);
unloadModel(floor);
closeWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------

View File

@ -31,7 +31,7 @@ const texture = loadTexture("resources/cubicmap_atlas.png"); // Load map text
//model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
const mat = loadMaterialDefault()
setMaterialTexture(mat, MATERIAL_MAP_DIFFUSE, texture)
setModelMaterial(model,0,mat)
setModelMaterial(floor,0,mat)
// Get map image data to be used for collision detection
const mapPixels = new Uint8Array(loadImageColors(imMap));
@ -93,7 +93,7 @@ while (!windowShouldClose()) // Detect window close button or ESC key
clearBackground(RAYWHITE);
beginMode3D(camera);
drawModel(model, mapPosition, 1.0, WHITE); // Draw maze map
drawModel(floor, mapPosition, 1.0, WHITE); // Draw maze map
endMode3D();
drawTextureEx(cubicmap, new Vector2(getScreenWidth() - cubicmap.width*4.0 - 20, 20.0), 0.0, 4.0, WHITE);
@ -112,7 +112,7 @@ while (!windowShouldClose()) // Detect window close button or ESC key
//--------------------------------------------------------------------------------------
unloadTexture(cubicmap); // Unload cubicmap texture
unloadTexture(texture); // Unload map texture
unloadModel(model); // Unload map model
unloadModel(floor); // Unload map model
closeWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------

View File

@ -56,7 +56,7 @@ setShaderValue(shader, ambientLoc, new Vector4(0.1, 0.1, 0.1, 1.0), SHADER_UNIFO
// Assign out lighting shader to model
const matModel = loadMaterialDefault()
matModel.shader = shader
setModelMaterial(model, 0, matModel)
setModelMaterial(floor, 0, matModel)
const matCube = loadMaterialDefault()
matCube.shader = shader
setModelMaterial(cube, 0, matCube)
@ -99,7 +99,7 @@ while (!windowShouldClose()) // Detect window close button or ESC key
clearBackground(RAYWHITE);
beginMode3D(camera);
drawModel(model, vector3Zero(), 1.0, WHITE);
drawModel(floor, vector3Zero(), 1.0, WHITE);
drawModel(cube, vector3Zero(), 1.0, WHITE);
// Draw spheres to show where the lights are
@ -123,7 +123,7 @@ while (!windowShouldClose()) // Detect window close button or ESC key
// De-Initialization
//--------------------------------------------------------------------------------------
unloadModel(model); // Unload the model
unloadModel(floor); // Unload the model
unloadModel(cube); // Unload the model
unloadShader(shader); // Unload shader

View File

@ -68,7 +68,7 @@ setShaderValue(shader, ambientLoc, new Vector4(0.1, 0.1, 0.1, 1.0), SHADER_UNIFO
// Assign out lighting shader to model
const matModel = loadMaterialDefault()
matModel.shader = shader
setModelMaterial(model, 0, matModel)
setModelMaterial(floor, 0, matModel)
setMaterialTexture(matModel, MATERIAL_MAP_DIFFUSE, texture)
const matCube = loadMaterialDefault()
matCube.shader = shader
@ -107,7 +107,7 @@ while (!windowShouldClose()) // Detect window close button or ESC key
clearBackground(RAYWHITE);
beginMode3D(camera);
drawModel(model, vector3Zero(), 1.0, WHITE);
drawModel(floor, vector3Zero(), 1.0, WHITE);
drawModel(cube, new Vector3(0,1,0), 1.0, WHITE);
if (light.enabled) drawSphereEx(light.position, 0.2, 8, 8, light.color);
@ -128,7 +128,7 @@ while (!windowShouldClose()) // Detect window close button or ESC key
// De-Initialization
//--------------------------------------------------------------------------------------
unloadModel(model); // Unload the model
unloadModel(floor); // Unload the model
unloadModel(cube); // Unload the model
unloadShader(shader); // Unload shader

3
examples/ts_dungeon/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
node_modules/
main.js
editor.js

1721
examples/ts_dungeon/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,25 @@
{
"name": "bindings",
"version": "1.0.0",
"description": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack --config webpack.config.js",
"watch": "webpack --watch --config webpack.config.js --mode development"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"ts-loader": "^9.4.2",
"ts-node": "^10.9.1",
"typescript": "^5.0.4",
"webpack": "^5.82.0",
"webpack-cli": "^5.0.2"
},
"dependencies": {
"inkjs": "^2.2.1",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.8.1"
}
}

View File

@ -0,0 +1,69 @@
# Changelog
## v9 (5th October, 2022)
- Added a small version of the limestone bricks, to match the red brick version.
- Added more small brick textures (red and limestone) with vines and grass.
- Added an archway cut-out version of the hedge texture.
- Added 3 dirt textures: one bare, one with stones, and one with a puddle.
- Added 3 sand textures: small pebbles, larger stones, and footsteps!
- Adjusted the colors of the grass texture.
## v8 (31st August, 2022)
- Updated the brick textures, increasing the spread of the bullet holes.
- Added 2 large sandstone brick textures.
- Added 2 steps textures to match the sandstone and red bricks.
- Renamed the existing step texture to ledge.
- Added 2 chain-link fence textures.
- Added 6 stucco textures, 3 of which have exposed red bricks.
- Added 3 hedge textures: sparse and dense variants, and a flowering variant.
- Added a grass texture.
- Adjusted the color of the BSOD terminal.
## v7 (26th August, 2022)
- Added 4 new brick textures, in 2 variants: large bricks and small bricks.
## v6 (8th July, 2022)
- Added 6 grid textures, with transparent versions.
- Added a brown slime textures.
- Added 6 new concrete textures, in two color variants.
- Added 2 new floor variants for both the tech lab and toxic lab themes.
- Added 2 new tech lab wall textures with air vents.
- The various support pillar textures have been split up into separate textures, rather then four compressed into each 64x64 texture.
- All of the textures have been lightened slightly.
## v5 (5th July, 2022)
- Added 30 new textures in a toxic waste lab theme: floors, ceiling lights, wall panels, support pillars and lights, doors, pipes, and slime.
- Added 6 new tech lab door textures for vertically opening doors.
- Added 6 new door trim textures.
## v4 (25th June, 2022)
- Added 4 computer panel textures, including one with a bullet hole, and one with the iconic BSOD!!!
- Added 6 door textures, in three trim variants: metal, yellow and red; with and without damage.
- Added versions of crates without pickup truck holes.
- Recolored the dark crate versions and gave them a unique design.
- Added crate tops for 64x64, 32x32, and 16x16.
- Added simplified pipes texture.
- Added 7 new tech walls, with no panel edges, ideal for making long corridors feel less repetitive.
## v3 (23rd June, 2022)
- Added 19 new stone tile ground textures, in three different variants: stone, mossy, and sandstone. For each variant there are two different layout patterns (square block and parquet), with various amounts of damage. The mossy version also has grass tuffs and water pools.
- Added 4 new crate textures, in smaller sizes: 32x16 and 16x16.
- Added 2 new rivets textures, for vertical strips of riveted metal, such as around doorways.
- Updated some of the crate textures to add in more details.
- Tweaked the lighting of most of the tech wall textures to soften them slightly.
- Improved the overview file, with labels to make it easier to find textures.
## v2 (21st June, 2022)
- Added 10 new textures, consisting of 5 different crates, in two color variants, in three different sizes: 64x64, 64x32, and 32x32.
## v1 (28th October, 2021)
- An initial collection of 58 textures, mostly tech facility themed.

View File

@ -0,0 +1,20 @@
Retro Texture Pack
Created/distributed by Craig Smith (little-martian.dev)
Creation date: 05-10-2022
------------------------------
License: (Creative Commons Zero, CC0)
http://creativecommons.org/publicdomain/zero/1.0/
This content is free to use in personal, educational and commercial projects.
Support us by crediting Little Martian or little-martian.dev (this is not mandatory)
------------------------------
Donate: https://little-martian.itch.io/
Follow on Twitter for updates:
https://twitter.com/MartiansGame

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 905 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 874 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 928 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1022 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 778 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 892 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 913 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 767 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 671 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Some files were not shown because too many files have changed in this diff Show More