How to make a simple drawing program?

Eloc

  • Posts: 13
I'm looking for a bit of help making a very simple drawing program, running a "while: mouse pressed" under drawing and telling it to fill pixel at mouse X&Y just crashes the program! Thanks!

Luyren

  • *
  • Posts: 1798
You need to use the image API. In short,
-Add a "Created" event to your behavior and do the following in it:
-Create an image attribute and an image instance attribute
-Set your image attribute to a blank image the size of your screen.
-Set your image instance attribute to an instance of that image attribute.
-Attach it to the screen at x: 0, y: 0

You then should be able to use with the mouse coordinates to draw pixels on your image.
I have my Stencyl resources available here: https://luyren.itch.io/

Eloc

  • Posts: 13
This was the created event I made, The drawing event was the same but with the set pixel block as you advised. Unfortunately the program still crashes. Sorry, I kinda know what I'm doing but kinda dont as well.

Luyren

  • *
  • Posts: 1798
You said you were using the "while" block on your first post. You have to use "If" inside an update event.

A while loop will run infinitely until the condition to exit it is met, and won't advance a frame until it exists the loop. In other words you are crashing your game with an infinite loop.
I have my Stencyl resources available here: https://luyren.itch.io/

Eloc

  • Posts: 13
Oh. It works now! Thank you so much! One last question before you go, my project screen is quite large, it there a way to make the pixels drawn larger? If I don't respond please have a good night!

Luyren

  • *
  • Posts: 1798
You can either:
1- Go to Settings > Web/Desktop > Select a higher scale OR
2- Use the and inside it use several of the block, drawing around your point to make it paint a bigger area per frame. So that would be at mouse position, X of mouse +1, X and Y of mouse +1 etc
I have my Stencyl resources available here: https://luyren.itch.io/

Eloc

  • Posts: 13
Alrighty! Thank you so much!  :D