Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Knox

#301
Thanks Wyz...thanks for your code snippit :)

I just need to figure out how to make the edges of the line look anti-aliased and we're all set. ;D
#302
Do you have parkinsons? ;D
#303
I started this thread a while ago but pretty much got my answers myself screwing around and what not: http://www.adventuregamestudio.co.uk/yabb/index.php?PHPSESSID=6ve262cd3e75q7svke88rgrs74&topic=43454.0

However, I ran into a problem:

Im not sure why but it seems that when I draw onto a gui with my "pen", the line is totally opaque (I cant see the semi-transparent "edge" of the "pen-dot" sprite to make the line look anti-aliased).

I tried a 2nd way by using a different script that I modified a bit (still contains bugs/errors), but its much closer to the effect Im searching for.

Here are the videos...how can I get Mode 1 (using a sprite + Wyz's BrushLine code) to match the second's anti-aliased look (Kweepa's DrawAntialiased v1.1: http://www.adventuregamestudio.co.uk/yabb/index.php?topic=39846.0)

Mode 1: http://www.youtube.com/watch?v=Wo0HpJN9f78

Mode 2: http://www.youtube.com/watch?v=IklxVuY06gg



SCRIPT:
Code: ags

DynamicSprite *dsWriteOnSurface;
DrawingSurface *DrawSurface;
Overlay *ovPen;
int iPenColor;
int iTrans = 0;

function BrushLine(this DrawingSurface*, int x1, int y1, int x2, int y2, int slot, float spread)
{
  x1 -= Game.SpriteWidth[slot] / 2;
  y1 -= Game.SpriteHeight[slot];
  x2 -= Game.SpriteWidth[slot] / 2;
  y2 -= Game.SpriteHeight[slot];
  
  float dx = IntToFloat(x2 - x1);
  float dy = IntToFloat(y2 - y1);
  
  float interval = Maths.Sqrt(dx*dx + dy*dy);
  interval = interval / (IntToFloat(Game.SpriteWidth[slot] + Game.SpriteHeight[slot]) / (spread * 2.0));
  
  if (interval < 1.0)
    interval = 1.0;
  
  float i = 0.0;
  float xoffset = dx / interval;
  float yoffset = dy / interval;
  float xx = IntToFloat(x1);
  float yy = IntToFloat(y1);
  
  while (i < interval)
  {
    this.DrawImage(FloatToInt(xx), FloatToInt(yy), slot, iTrans);
    xx += xoffset;
    yy += yoffset;
    i++;
  }
}

void DynamicDraw(this Button*, int iMode)
{
  if (iMode == 1) //Draw BrushLine with Sprite ON GUI
  {
    if (bIsDrawing == true) 
    {
      if (Mouse.IsButtonDown(eMouseLeft) == true) 
      {
        iPenColor = 2720; //Black pen Small

        dsWriteOnSurface = DynamicSprite.CreateFromExistingSprite(this.NormalGraphic);
        DrawSurface = dsWriteOnSurface.GetDrawingSurface();			
        DrawSurface.BrushLine(mouse.x-iGuiX, mouse.y-iGuiY, iPrevX-iGuiX, iPrevY-  iGuiY, iPenColor, 20.0);
					
        //Anti-Aliased:	
        //int iX = mouse.x-iGuiX;
        //float fX = IntToFloat(iX);
        //int iY = mouse.y-iGuiY;
        //float fY = IntToFloat(iY);
        //int iX2 = iPrevX-iGuiX;
        //fPrevX = IntToFloat(iX2);
        //int iY2 = iPrevY-iGuiY;
        //fPrevY = IntToFloat(iY2);
        //DrawAntialiasedLine(DrawSurface, fX, fY, fPrevX, fPrevY, 0);
							
        this.NormalGraphic = dsWriteOnSurface.Graphic;
        iPrevX = mouse.x;
        iPrevY = mouse.y;
        //fPrevX = IntToFloat(iPrevX);
        //fPrevY = IntToFloat(iPrevY);			
      }
      else bIsDrawing = false;
    }
  }  
}

void on_event (EventType event, int data)
{
 if (oTg == gTicketBook_Cit)
 {
  bIsDrawing = true;
  iPrevX = mouse.x;
  iPrevY = mouse.y;  
  //fPrevX = IntToFloat(iPrevX);
  //fPrevY = IntToFloat(iPrevY);    
  return;
 }
 else 
 {
  if (bIsDrawing == true) bIsDrawing = false;
 }	
}

function repeatedly_execute() 
{ 
  if (gTicketBook_Cit.Visible && mouse.GetModeGraphic(eModePointer) == 3901)
  {
    iGuiX=484;
    iGuiY=152;
    btnCitation.DynamicDraw(1);
  }
}
#304
@tzachs: Nice! Do you think that it's also possible to drag tabs to change their order so a tab that's last can be grabbed, and dropped into the first position?

#305
@tzachs: I figured you would most probably be the one deciding if this is doable:

Do you think we can make the "edit custom properties" window resizable? Right now (for me anyways, windows 7 x64), it isnt resizable...since I currently have many custom properties, its a biatch having to scroll through a very small window!

ps: Do you think there will be future possibilities to have a whole menu section for "saving/loading user layouts"...so you can save a layout as a .agsUI file (or something) + load it in other copies of AGS on different computers (it would save window sizes, locations, font, template colors, preferences, etc).
#306
Ok, since I got it to work on the background, Im now trying to draw onto a gui instead of the background...but I keep on making AGS crash...how do I draw onto the gNotePad gui? It should save pen drawing onto the gNotePad.BackgroundImage, but this is not working:

Code: ags

function repeatedly_execute() 
{               
 if (bIsDrawing == true) 
  {
    if (Mouse.IsButtonDown(eMouseLeft) == true) 
    {
      //Display("Draw!");
      int iPenColor = 2716; //Blue pen
      //int iPenColor = 2718; //Black pen
      //int iPenColor = 2720; //Red pen
      //int iPenColor = 3853; //Highlighter
      
      //A:
      //DrawingSurface *DrawSurface = Room.GetDrawingSurfaceForBackground();
      
      //B:
      DynamicSprite *dsNotePad = DynamicSprite.CreateFromExistingSprite(gNotePad.BackgroundGraphic);
      //DynamicSprite *dsNotePad = DynamicSprite.CreateFromExistingSprite(3854);
      DrawingSurface *DrawSurface = dsNotePad.GetDrawingSurface();

      DrawSurface.BrushLine(mouse.x, mouse.y, iPrevX, iPrevY, iPenColor, 7.0);
      DrawSurface.Release();
      
      //B:
      gNotePad.BackgroundGraphic = dsNotePad.Graphic;
      //Wait(120);
      //dsNotePad.Delete();

      iPrevX = mouse.x;
      iPrevY = mouse.y;
    }
    else bIsDrawing = false;
}

function on_mouse_click(MouseButton button) 
{
  if (button == eMouseLeft) 
  {
    bIsDrawing = true;
    iPrevX = mouse.x;
    iPrevY = mouse.y;
  }
}




**UPDATE: OK, I need to declare the dynamic sprites outside the function, sorry guys for my posts!!

QuoteIn order to use DynamicSprites as button or GUI backgrounds, they have to be defined outside any function (otherwise they are destroyed as soon as the function finishes, ending the element that uses them up at displaying sprite 0/the blue cup).
#307
Ok I think I got it!

(but using Wyz' brushLine instead of the AntiAlias Line code)

Code: ags

function repeatedly_execute() 
{               
  if (bIsDrawing == true) 
  {
    if (Mouse.IsButtonDown(eMouseLeft) == true) 
    {
      int iPenColor = 2716; //blue pen ...2718 black pen ...2720 red pen
      DrawingSurface *DrawSurface = Room.GetDrawingSurfaceForBackground();
      DrawSurface.BrushLine(mouse.x, mouse.y, iPrevX, iPrevY, iPenColor, 7.0);
      iPrevX = mouse.x;
      iPrevY = mouse.y;
    }
    else bIsDrawing = false;
  }
}

function on_mouse_click(MouseButton button) 
{
  if (button == eMouseLeft) 
  {
    bIsDrawing = true;
    iPrevX = mouse.x;
    iPrevY = mouse.y;
  }
}

Is this a good way?
#308
Im just trying to do a basic pencil function for free-hand drawing with AGS. I looked here for code snippets:

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=41620.0
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=39846.0


Code: ags

  if (bIsDrawing == true) 
  {
    if (Mouse.IsButtonDown(eMouseLeft) == true) 
    {
      DrawingSurface *DrawSurface = Room.GetDrawingSurfaceForBackground();
  
      float fMouseX = IntToFloat(mouse.x);
      float fMouseY = IntToFloat(mouse.y);
      DrawAntialiasedLine(DrawSurface, fMouseX, fMouseY, fMouseX*1.2, fMouseY*1.2, 0); <--what do I put here for smooth lines?

      DrawSurface.Release();
    }
    else bIsDrawing = false;
  }



To make the mouse draw a nice anti-aliased line smoothly with hand gestures to simulate a pencil is what Im going for. Im almost there, but I think Im getting the math wrong for the second "x" and "y" values...(I tried varations without luck because I dont understand what Im doing there...just pluggin arbitrary operators to see what happens.)
#309
ah crap, ok I see! Ill try something else then.

**I used some old voodoo magic I learnt from my neighbour and I can now do stuff inbetween game loops! Ill post the incantation if anyone else is interested :)
#310
Diggin' up a ooolldd thread :)

Hey Monkey,

Do you know if there is currently any way to have "int delay" a float instead? It seems for my page-flipping animations, if I set it to 1 its a bit slow, but at 0 its way way too fast (we dont even see  the animation)...I was thinking perhaps a delay of something like 0.5 could do the trick:

float delay instead of int delay?
Code: ags
gQG_PageTurnGUI.Animate(iLoop, 0.5, eOnce, eBlock, eForwards); 



#311
Hey Monkey,

If you have a chance today (may 1st), go to Google homepage...there's a magnifier "effect" they are using whe you go over the google logo...which is pretty much like yours, no?

Kinda cool.
#312
I thought of a few suggestions, what do you think about these?

1) Merging Calin's alpha plugin into AGS so you no longer need the plugin would be cool!

2) No more problems with alpha channels with the GUI's + buttons  (yay!)

3) Have alpha-blending/semi-transparent/translucent sprites working for our text windows

4) Merging Helios' customProperties Helper into AGS so we dont need the plugin

5) Making AGS games work on the IPhone/IPad (quadruple yay!) *dont even know if this is possible

6) Making ViewFrame.Speed not read-only

7) Dynamically drawing over Gui's/Overlays that draw over gui's (?)
#313
ah crap, no it doesnt...crap crap crap!

Didnt think of that :P

Ok well Ill see if I will change to a font that does, or just use an underscore.

Thnx Monkey
#314
Sorry to dig up an old thread but I was trying to display a '|' sign like Ryan, and Im not sure how he did it... I checked out Tidbits and Snippets: http://americangirlscouts.org/agswiki/AGS_tidbits_&_snippets but can't seem to find how to display/append the '|' character.

...this is what I tried (basically any combination I semi-know about):

(blah blah).Append("\"|\"");
(blah blah).Append("\|");
(blah blah).Append("%|");
(blah blah).Append(%s, "|");

grrr!
#315
Well when you set the sprite number the 1st time it does resize automatically, the 2nd + times, in my case (just retested), it doesnt resize automatically if the next sprite is smaller than the 1st :(
#316
For someone who doesnt know a thing about Allegro 5 and technical engine stuff...what can Allegro 5 actually do (other than bigger resolutions) to make AGS better? Will the alpha problems/work arounds for gui's/buttons we have now be fixed...faster drawing/frame rates, better video support, etc?
#317
It would be nice to have a random field for view frame delays...as in, instead of putting a fixed number, the user can type in "1-3" or "33-55" and AGS will choose randomly a delay number from what is typed in (we can do this manually but it would be cool to have it in the editor already).

Also, I is it possible to have a checkbox for buttons that says "Always resize to new Sprite"...that way, if you have a button that is 30x30, and you change it's graphic to a 45x45 sprite, the values for the H+W will update to 45x45...right now you have to manually change those values after changing the sprite.
#318
Im guessing an "engine feature request" thread will pop-up/resurface soon?

:)

Awesome news for the community!! Yes!!
#319
ah crap!! Ok, programming 101 :)

Well geeze I need to go through all my scripts and remove those checks then...

For the slowdown, Ill get you an example later today, I noticed sometimes it would go down 20 fps on certain lines in rep_exec without a "check" (but i think it was something more complex like the dynamic redraw!)
#320
I think the main main reason why I added that check is when Im inside the rep_exec. If I have a line like "btnMyBtn.NormalGraphic = 17", it can slow down the fps since its always changing the sprite...so I added a "check" to make sure it only does it once:

Code: ags
if (btnMyBtn.NormalGraphic != 17) btnMyBtn.NormalGraphic = 17; 


...so I just figured I'd add the same "check" to most of my lines (so it will only do it once in rep_exec)...in this case is it still a useless idea?

That is the main reason I guess <shrug>  :P
SMF spam blocked by CleanTalk