Drawing inside the game

Started by cAlien_Interact, Sat 13/02/2021 01:41:00

Previous topic - Next topic

cAlien_Interact

Code: ags

function FE4_Interact()
{

if (Mouse.IsButtonDown(eMouseLeft))
     {
          DrawingSurface* ds = Room.GetDrawingSurfaceForBackground();
          ds.DrawingColor = Game.GetColorFromRGB(255,100,255);
          ds.DrawRectangle(mouse.x - 1, mouse.y - 1, mouse.x + 1, mouse.y + 1);
          ds.Release();
     }

}
//and next

function g5g_AnyClick()
{
  aBlop.Play();
  Display("Nice drawing...you dig great");
  player.ChangeRoom(1, 90, 160, eDirectionRight);
 
}


this is the code I have for drawing on my surface, it does not let me draw, only click-draw, pixel by pixel(click by click)
How do i change this so u can draw holding down leftmousebutton as you would in Mspaint, instead of clicking pixel by pixel?

If anyone knows, that could help out, thanks alot!!! :cheesy:

Crimson Wizard

I have no idea what "FE4_Interact" is or how is it called. But usually you put code like this in "repeatedly execute" room event.

If you want this to happen only under certain conditions, then you have to do some adjustments, but that's another question.

cAlien_Interact

it's just a wall i have inside a room. i want to be able to draw on it

Crimson Wizard

Quote from: cAlien_Interact on Sun 14/02/2021 20:54:10
it's just a wall i have inside a room. i want to be able to draw on it

You want to draw on a room background or room object?

If you want to draw only on a part of room background, then it may be better to put an object there, create DynamicSprite, assign to that object, and draw on that DynamicSprite instead.

Otherwise you will have to also put additional condition there that will prevent from drawing outside certain area.

cAlien_Interact

The wall is an object, and it works to draw on it, not outside it, problem is the lines drawn is not continous, cant hold down...click click

Crimson Wizard

#5
Quote from: cAlien_Interact on Tue 16/02/2021 01:18:51
The wall is an object, and it works to draw on it, not outside it, problem is the lines drawn is not continous, cant hold down...click click

To fix that you'd simply need to move the drawing code into room's "repeatedly execute" event.

But then you also need to test if the mouse is above this object:
Code: ags

     if (Mouse.IsButtonDown(eMouseLeft) && Object.GetAtScreenXY(mouse.x, mouse.y) == FE4)
     {
          DrawingSurface* ds = Room.GetDrawingSurfaceForBackground();
          ds.DrawingColor = Game.GetColorFromRGB(255,100,255);
          ds.DrawRectangle(mouse.x - 1, mouse.y - 1, mouse.x + 1, mouse.y + 1);
          ds.Release();
     }


Here I assume that the object is called FE4, if not, just change the name in condition.

cAlien_Interact

Yes FE4 is correct, will try it out, thanks

Quote from: Crimson Wizard on Tue 16/02/2021 01:26:21
Quote from: cAlien_Interact on Tue 16/02/2021 01:18:51
The wall is an object, and it works to draw on it, not outside it, problem is the lines drawn is not continous, cant hold down...click click

To fix that you'd simply need to move the drawing code into room's "repeatedly execute" event.

But then you also need to test if the mouse is above this object:
Code: ags

     if (Mouse.IsButtonDown(eMouseLeft) && Object.GetAtScreenXY(mouse.x, mouse.y) == FE4)
     {
          DrawingSurface* ds = Room.GetDrawingSurfaceForBackground();
          ds.DrawingColor = Game.GetColorFromRGB(255,100,255);
          ds.DrawRectangle(mouse.x - 1, mouse.y - 1, mouse.x + 1, mouse.y + 1);
          ds.Release();
     }


Here I assume that the object is called FE4, if not, just change the name in condition.

SMF spam blocked by CleanTalk