banananas
banananas
DDeno
Created by banananas on 10/11/2024 in #help
Getting the width and height of an image
I'm trying to get the width and height of an image but I'm not sure how to do so. Could anyone tell me how?
5 replies
DDeno
Created by banananas on 10/7/2024 in #help
(Littledivy's SDL2 bindings) textures not loading properly
I'm using this script:
// main.ts
import {WindowBuilder, EventType, Rect} from "sdl";
import img from "./utils/img.ts";

export const winScale = 4;

const windowbuilder: WindowBuilder = new WindowBuilder("UNDERTALE Twilight", 332 * winScale, 259 * winScale)
.highPixelDensity()
.borderless()
.transparent()

const window = windowbuilder.build()
export const canvas = window.canvas();
export const cAnchor = [6, 11];

while (true) {
// input
for await (const event of window.events()) {
switch (event.type) {
case EventType.Quit:
Deno.exit(0);
break;
}
}

// render
canvas.clear();
const wintex = img("./window.png", canvas.textureCreator());
canvas.copy(wintex, new Rect(0, 0, 332, 259), new Rect(0, 0, 332, 259));
canvas.present();
}
// main.ts
import {WindowBuilder, EventType, Rect} from "sdl";
import img from "./utils/img.ts";

export const winScale = 4;

const windowbuilder: WindowBuilder = new WindowBuilder("UNDERTALE Twilight", 332 * winScale, 259 * winScale)
.highPixelDensity()
.borderless()
.transparent()

const window = windowbuilder.build()
export const canvas = window.canvas();
export const cAnchor = [6, 11];

while (true) {
// input
for await (const event of window.events()) {
switch (event.type) {
case EventType.Quit:
Deno.exit(0);
break;
}
}

// render
canvas.clear();
const wintex = img("./window.png", canvas.textureCreator());
canvas.copy(wintex, new Rect(0, 0, 332, 259), new Rect(0, 0, 332, 259));
canvas.present();
}
With this script:
// utils/img.ts
import { Surface, Texture, TextureCreator } from "sdl";

export default function img(
image: string,
creator: TextureCreator,
): Texture {
const trackSurface = Surface.fromFile(image);
return creator.createTextureFromSurface(trackSurface);
}
// utils/img.ts
import { Surface, Texture, TextureCreator } from "sdl";

export default function img(
image: string,
creator: TextureCreator,
): Texture {
const trackSurface = Surface.fromFile(image);
return creator.createTextureFromSurface(trackSurface);
}
And using deno run --unstable-ffi --allow-ffi --allow-env main.ts (I'm pretty sure) this should render window.png at position 0, 0 on the screen, however it doesn't do that. On another note, the .transparent() method on the WindowBuilder class doesn't seem to actually make the window transparent. Could anyone help me to fix this issue? Thanks in advance.
18 replies
DDeno
Created by banananas on 10/6/2024 in #help
[SOLVED] dlopen failing
When I try to use Deno.dlopen() like this:
Deno.dlopen("./SDL2.dll", {} as const);
Deno.dlopen("./SDL2.dll", {} as const);
I get the following error:
error: Uncaught (in promise) TypeError: Deno.dlopen is not a function
Deno.dlopen("./SDL2.dll",{} as const);
^
error: Uncaught (in promise) TypeError: Deno.dlopen is not a function
Deno.dlopen("./SDL2.dll",{} as const);
^
Does anyone know why this could be happenning and how I could solve it? Thanks in advance.
4 replies
DDeno
Created by banananas on 9/8/2024 in #help
Can't install Deno on Windows
I'm trying to install deno using PowerShell using the command provided in the Deno installation guide (irm https://deno.land/install.ps1 | iex). However, when I run this command, I get the following error:
Remove-Item : Cannot find path 'C:\Users\piotr\.deno\bin\deno.zip' because it does not exist.
At line:39 char:1
+ Remove-Item $DenoZip
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\piotr\.deno\bin\deno.zip:String) [Remove-Item], ItemNotFoundEx
ception
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand
Remove-Item : Cannot find path 'C:\Users\piotr\.deno\bin\deno.zip' because it does not exist.
At line:39 char:1
+ Remove-Item $DenoZip
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\piotr\.deno\bin\deno.zip:String) [Remove-Item], ItemNotFoundEx
ception
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand
Can someone help me as to why this happens?
2 replies