Questions tagged [rust-piston]

A modular game engine written in Rust.

34 questions
1
vote
0 answers

Issue with CharacterCache in piston_window in Rust

I am currently working on a project in Rust with the piston game engine (Using piston_window version 0.123.0) and I am having an issue with rendering text. The draw function returns an error fro a non implemented trait. Here is the code: // Get font…
Krone
  • 23
  • 3
1
vote
0 answers

Text-wrapping and text-backgroud-color in Piston-2DGraphics (Rust)?

1 - How to wrap text to the next line, once it's out of the window. 2 - How do we handle the background-color of a text field. I'm very new to game dev, so this might be a naive question to ask.
Ritwik
  • 1,597
  • 16
  • 17
1
vote
2 answers

Piston application crashes after a few minutes with a memory allocation error

I've developed a maze game using Piston in Rust in order to teach myself graphics/UI programming. The game mostly works fine, but when I run it with a large maze (e.g. 120 x 72 rectangles), the game crashes with a memory allocation error after a…
isaacg
  • 593
  • 6
  • 19
1
vote
1 answer

Piston GenericEvent not implemented for Event

I am trying to write a game in Rust using piston_window(0.77.0) library. Starting from their hello world example I thought I would start by separating of rendering logic into a method using Event as parameter since according to documentation it is…
Januson
  • 4,533
  • 34
  • 42
1
vote
1 answer

Efficiently draw paths using piston

Piston's graphics library provides a function for drawing a line between two points, but nothing for more than two. How do I efficiently draw a path through many points without having to draw a line for every segment? Let's say I have the following…
Sunjay Varma
  • 5,007
  • 6
  • 34
  • 51
1
vote
1 answer

Type mismatch when calling sprite::Scene::draw

I am working on a personal project using Piston and Sprite. The example code calls this method: scene.draw(c.transform, g); I am trying to call a method to draw everything. I first tried: draw(&self, c: &Context, g: &mut G, scene: &mut…
P bertJoha
  • 96
  • 2
  • 10
1
vote
1 answer

How can the resolution of a PistonWindow be changed after creation?

I'd like to change the resolution of a PistonWindow after it has been created. This would allow a user to change the resolution of the window while playing the game. WindowSettings has a set_size method, but it doesn't seem to be accessible after…
phoenix
  • 7,988
  • 6
  • 39
  • 45
0
votes
1 answer

There was a problem printing text using piston_window

When I tried to print text using the piston_window library, I found that the "10" was printed and only the "1" was displayed.Here is the code. use piston_window::types::Color; use piston_window::{text, Context, G2d, Glyphs, Transformed}; pub const…
DeFan
  • 3
  • 2
0
votes
1 answer

piston-opengl_graphics: `can't find crate`

I am building a piston program, which I committed yesterday. When running it unchanged today ( cargo run / cargo check), these are my error messages from the piston-opengl_graphics crate: can't find crate for x for most of its dependancies; which…
CoDeus
  • 1
  • 3
0
votes
1 answer

Rust Piston can't find correct type hint

I am New to Rust and come from another programming language. here are my dependencies [dependencies] piston_window = "0.123.0" piston = "0.53.1" gfx = "0.18.2" I am having a problem with the manual type hinting when I load a Texture without adding…
reyop
  • 3
  • 1
0
votes
1 answer

rust piston rectangle function does not work within the loop

I want to draw a lot of cells based on 2d array in rust piston library. I try to edit hello world example and have function like so: fn render(&mut self, args: &RenderArgs) { const GREEN: [f32; 4] = [0.0f32, 1.0f32, 0.0f32, 1.0f32]; const…
Nikolai Savulkin
  • 697
  • 5
  • 12
0
votes
1 answer

Piston create a a block of multiple square

i want to create something like a square of square like a a square composed of 4 small squares (4x4) for a Tetris I know how to create a simple square and move it, but I don't know how to create a more complex figure like a 4x4 square or an L and…
Zenmoa
  • 31
  • 5
0
votes
0 answers

Why does Piston render a blank window on macOS?

I am trying to run the Piston Getting Started Tutorial on my MacBook Pro. When running the example with cargo run, only a blank window appears with no rendering: Why are the graphics are not rendering? Edit: For anyone in a similar situation,…
scruffaluff
  • 345
  • 4
  • 20
0
votes
2 answers

function or associated item not found for image::ImageBuffer::from_vec()

I'm using Piston's image crate, with this code: use image::{Rgb, ImageBuffer, Pixel}; let image = Vec::>::new(); let image_buffer = ImageBuffer::, Vec>>::from_vec( width, height image, ).unwrap(); However I get…
Timmmm
  • 88,195
  • 71
  • 364
  • 509
0
votes
1 answer

Cannot compile stb_truetype 0.2.4 because "slice pattern syntax is experimental"

I was following a tutorial on how to setup the piston library, but when I tried to compile it I got the following error message: error[E0658]: slice pattern syntax is experimental (see issue #23121) -->…