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

#181
I use void instead of function, well cause Monkey uses that and he's cool.
#182
Cool, thats exactly what I chose to do, it works! Only thing left to do now is find a way to make the "alpha sprite" version run faster. The "Draw" way with magic pink works nice and fast now.

ps: I can post the results if anyone wishes!
#183
I'd like to re-download this plugin but the link seems to be broken. Would anyone have a copy somewhere?
#184
lol, wow, must have been on high-grade quality acid! I honestly dont remember that plugin or post, heh. Cool, well uhh...yah I going to recheck that out now. So uhh...yah :)

thnx
#185
Hi guys,

I was wondering: can a user make a custom font that uses "alpha sprites" instead of characters (A, B, C, etc)...and then use the DrawString function to draw transparent pink to dynamic sprites? The text you type would correspond to the various alpha sprites you placed in the font file.
#186
Oooohhhh!! Ah ok now I see :)

Wow, yeah, thats even better! Ok, gonna try that out now.
Thanks!
#187
@Calin:
Specs:
HP Workstation z400 Zeon W3530 2.8GHz
12 GB of RAM
NVIDIA GeForce GTX 560HP
I'm really trying to make "heavy" features toggable in the game settings, like turning off shadows, certain effects, etc...I really dont want to exclude low end/normal machines!!

@Wizard:
I've got a check that if the (!player.IsMoving), I dont redraw. I'm pretty sure Im already doing steps 1 to 4, but instead of drawing the shadow on the background, I draw the shadow to the object's graphic because Im guessing drawing the a smaller sprite 340x340 is better/fster than redrawing to the whole screen (?) Perhaps I dont understand something so forgive my ignorance!

Here is my code (without the global variables, small functions here and there, etc):

Code: ags

function room_RepExec()
{
  if (bMoving) player.GetZones();
  cShadow.Loop = player.Loop;
  
  if (bShadowInitialize && !(player.Moving))
  {
    //in the game settings you can turn shadows on/off, when set to on, query the zone the player is over
    if (bActivate_ZoneA) cShadow.ShadowInitialize(oLongGrass_A, 1);
    if (bActivate_ZoneB) cShadow.ShadowInitialize(oLongGrass_B, 2);
    if (bActivate_ZoneC) cShadow.ShadowInitialize(oLongGrass_C, 3);
    if (bActivate_ZoneD) cShadow.ShadowInitialize(oLongGrass_D, 4);
    if (bActivate_ZoneE) cShadow.ShadowInitialize(oLongGrass_E, 5);
    if (bActivate_ZoneF) cShadow.ShadowInitialize(oLongGrass_F, 6);
  }
  if (player == cTractor && player.Moving)
  {
    if (!bMoving) bMoving = true;
    iLoop = player.GetCharacterDirection(); //get the direction so we can adjust the mower's cutting width
    if (bShowShadow && !bShadowOff)
    {
      if (bActivate_ZoneA) oLongGrass_A.DrawOnShadowReceiver(4769, 1);
      if (bActivate_ZoneB) oLongGrass_B.DrawOnShadowReceiver(4779, 2);
      if (bActivate_ZoneC) oLongGrass_C.DrawOnShadowReceiver(4780, 3);
      if (bActivate_ZoneD) oLongGrass_D.DrawOnShadowReceiver(4781, 4);
      if (bActivate_ZoneE) oLongGrass_E.DrawOnShadowReceiver(4782, 5);
      if (bActivate_ZoneF) oLongGrass_F.DrawOnShadowReceiver(4783, 6);
    }
  }
  
  if (!bShowShadow) 
  {
      if (bShadowOff && player.Moving)
      {
        if (bActivate_ZoneA) oLongGrass_A.ClearShadowReceiver(4769);
        if (bActivate_ZoneB) oLongGrass_B.ClearShadowReceiver(4779);
        if (bActivate_ZoneC) oLongGrass_C.ClearShadowReceiver(4780);
        if (bActivate_ZoneD) oLongGrass_D.ClearShadowReceiver(4781);
        if (bActivate_ZoneE) oLongGrass_E.ClearShadowReceiver(4782);
        if (bActivate_ZoneF) oLongGrass_F.ClearShadowReceiver(4783);
      }
  } 

void ShowShadow(this Character*, Object* onWhat, int iZone)
{
  if (bShowShadow == true)
  {

    cShadow.Loop = player.Loop;
    //first clear any shadows on surface by reverting back to original object surface's sprite...in room script

    dsSource = DynamicSprite.CreateFromExistingSprite(onWhat.Graphic, true);
    if (iZone == 1) dsApplyShadow_A = DynamicSprite.CreateFromExistingSprite(onWhat.Graphic, true);
    else if (iZone == 2) dsApplyShadow_B = DynamicSprite.CreateFromExistingSprite(onWhat.Graphic, true);
    else if (iZone == 3) dsApplyShadow_C = DynamicSprite.CreateFromExistingSprite(onWhat.Graphic, true);
    else if (iZone == 4) dsApplyShadow_D = DynamicSprite.CreateFromExistingSprite(onWhat.Graphic, true);
    else if (iZone == 5) dsApplyShadow_E = DynamicSprite.CreateFromExistingSprite(onWhat.Graphic, true);
    else if (iZone == 6) dsApplyShadow_F = DynamicSprite.CreateFromExistingSprite(onWhat.Graphic, true);
    
    player.GetShadowSprite();

    iShadowSpriteBkp = iShadowSprite;
    
    iShadowAreaW = Game.SpriteWidth[iShadowSprite];
    iShadowAreaH = Game.SpriteHeight[iShadowSprite];
    
    getZoneAdjustment(iZone);
    
    int iX = this.x - (iShadowAreaW/2) + iXzoneAdjust; //substract the length of the sprite + ifactor
    int iY = this.y - (iShadowAreaH/2) + iYzoneAdjust + iYadjust;
    
    if (iZone == 1) DrawSprite(dsApplyShadow_A.Graphic, iShadowSprite, iX, iY, eBlendMultiply, 0); //draw shadow on top 
    else if (iZone == 2) DrawSprite(dsApplyShadow_B.Graphic, iShadowSprite, iX, iY, eBlendMultiply, 0); //draw shadow on top 
    else if (iZone == 3) DrawSprite(dsApplyShadow_C.Graphic, iShadowSprite, iX, iY, eBlendMultiply, 0); //draw shadow on top 
    else if (iZone == 4) DrawSprite(dsApplyShadow_D.Graphic, iShadowSprite, iX, iY, eBlendMultiply, 0); //draw shadow on top 
    else if (iZone == 5) DrawSprite(dsApplyShadow_E.Graphic, iShadowSprite, iX, iY, eBlendMultiply, 0); //draw shadow on top 
    else if (iZone == 6) DrawSprite(dsApplyShadow_F.Graphic, iShadowSprite, iX, iY, eBlendMultiply, 0); //draw shadow on top 
    
    if (iZone == 1) onWhat.Graphic = dsApplyShadow_A.Graphic;
    else if (iZone == 2) onWhat.Graphic = dsApplyShadow_B.Graphic;
    else if (iZone == 3) onWhat.Graphic = dsApplyShadow_C.Graphic;
    else if (iZone == 4) onWhat.Graphic = dsApplyShadow_D.Graphic;
    else if (iZone == 5) onWhat.Graphic = dsApplyShadow_E.Graphic;
    else if (iZone == 6) onWhat.Graphic = dsApplyShadow_F.Graphic;
    iShadowSprite = iShadowSpriteBkp;
  }
}

#188
No, before I was doing that and getting 30fps drops!! Thats why now I decided to divide the screen into 6 zones of 340x340 objects. I just redraw the graphic of whatever object the tractor is currently over with the shadow in multiply mode.

Is there a even better way? Right now with this solution Im only  getting a 5-10fps drop, so it seems much more efficient than before!
#189
Hey guys!

I found a solution for another problem I was fixing at the same time, and I think I can use that solution for this one (cutting the grass effect):

I wrote some scripts to enable shadows in multiply mode on the tractor (which I will re-use for the player character and driving module, yay). I can post them if anyone wants it.

I realized drawing all this stuff to a large 1024x768 sprite every loop is way too heavy + slow, so I divided up the "grass area" into 6 pieces of 340x340 each on its own object. Then I wrote a script that detects what zone (object) the tractor is in/over. If the tractor is in 4 zones (over 4 objects) at once (maximum), then redraw the shadow for those zones...obviously if the tractor is over just 1 zone, then that's when the script works the fastest.

For a non-programmer like me, man it feels good to get something like this to work, hehe! Very rewarding. Took me a whole freakin 3 days to figure it out, I bet Monkey/Khris/Wizard and the like would have taken 5 min.

Here is a video of the results, which now I will try to apply the same thing to "cutting the grass away"

View My Video

Almost there!! :)
#190
Hehe...well maybe I will if I cant figure something out!

Ill even pay him if he wants...but guys keep refusing here! :)
#191
Crap, I know I can't program my own plugin, so I'll have to figure out another solution for this I think. I'm thinking maybe make the surface area for the "cut grass mini-game"  alot smaller than 1024x768.

I wish there was an easier/faster way to "paint" onto a sprite's alpha channel, using another sprite as the "brush" shape. I got it to work fine with the DrawLine though. Too bad I can't use "magic pink" with the DrawAlpha() function...it just draws to the RGB. DOh!

#192
@DKH: Oups, I made a typo while transcribing it to the forums, thanks for catching that :)

@Crimson Wizard: Wow, cool! Didnt know that. It definitely fixed the error problem, although I now have a new problem related to the AGSBlend plugin...plus its way too slow processing the whole screen pixel by pixel for what I want it to do...I believe I need to rethink this :)

Im gonna try to debug that part, but might post a follow-up question if I cant figure it out.

Thanks for your help guys!
#193
I get this error "Script appears to be hung (a while loop ran 150001 times). The problem may be in a calling function; check the call stack."when I try to run the code below:

Code: ags

  while (iY1 < dsSourceGraphic.Height) //768
  {
    while (iX1 < sSourceGraphic.Width) //1024
    {
      //iAlpha = GetAlpha(dsLongGrass.Graphic, iY1, iX1);
      //ds.DrawingColor = Game.GetColorFromRGB(iAlpha,iAlpha,iAlpha); //this is a grey color representing the alpha.
      //ds.DrawPixel(iX1,iY1); // draw the alpha to the copy.
      iX1++;
    }
    iY1++;
    iX1 = 0;
  }


I've been using that "while snippet" throughout my game, but it only works when the dynamic sprite "dsSourceGraphic" is square (70x70, for example). How do I get it to work with a rectangle? (1024x768)

Its being used to go through the dynamic sprite's pixels to copy the alpha channel.
#194
Ok, so Ive got it to work using draw line set to the proper thickness of where the mower blades are + magic pink. Now my next step is to use an "alpha" sprite "cutter" that cuts away the grass with jagged edges instead of the DrawLine function (cause right now it doesn't look realistic since it "cuts" in super straight edges)...I'll fiddle with Calin's "PutAlpha" in his AGSBlend plugin and see what I come up with.

In the meantime, I was wondering if this was possible below? While clearing the dynamic sprite away with magic pink, is it possible to also add a "shadow" underneath where the grass is cut, so it acts like the vid below in photoshop? I'm guessing I'd have to make a copy of what section of grass is being cut in the room's rep_exec, displace it downward, fill it with a dark green shadow color, blur it and then set the opacity to like 50%...then redraw the grass over that?

View My Video

#195
Hi guys,

Ive got the art setup and was wondering what size for the tractor do you prefer? Also, in your opinion, should I go with a large scrollable background for the minigame of cutting grass, or stick to 1024x768? I was thinking of adding "hazards" like rocks, bottles, tree branches, etc...that the player has to avoid, if not the blades get jammed + motor chokes, hehe!

[img=http://s7.postimage.org/ly59dcwh3/screen1.jpg]
[img=http://s12.postimage.org/a974qllhl/screen2.jpg]
#196
Oh wow, ok this really is way over my head. Im seriously thinking of taking night classes after work in programming. I can fiddle around, hacking my way through but it would be really nice to fully understand everything I am doing, heh! Ive always been on the art side but I have to admit, the more I dabble in writing code, the more I love it...serious fun :)

I appreciate your help guys, I think I will wisely back off from this for now.
#197
I guess this is way beyond my current skills!
#198
Hi,

I downloaded Skygoblin's "master" (not sure what that is, master "build" I guess) and I copied the contents inside the bin folder to my AGS editor folder. Everything works fine, I now can have custom resolutions (yay!).

What Id like to know, (really stupid question), is how do I modify various editor values + "recompile"? Id like to change MAX_INIT_SPR to 60 inside acroom.h + recompile (means increasing the max objects per room to 60, right?)...but with what program do I use? Some c++ kind of program? Plus, Id like to increase the maximum amount of gui controls above 30, but where do I find that value?

If there is a newbie tutorial on all this, sorry but I looked and really couldnt find it!

PS: Also, if Id like to keep the draconian editor's changes (awesome), but merge it with skygoblin's changes, how would one do that? I realize this will probably get me an answer like "go take a programmer's course", hehe..which Im thinking of doing...(what classes would you suggest for ags type scripting and editor changes, etc?)

**EDIT: OK, I need visual studio.
#199
Awesome, Im going to try those suggestions now :)

Thanks guys!
#200
I'm trying to code a mini-game where the main player cuts his lawn. I was thinking Id divide the room up into squares and place dynamic sprites with the uncut grass texture on them. When the player moves from one square to the next, I'd clear/delete the dynamic sprite to reveal the room's background underneath, which would have the cut grass texture.

Something like this: (Space Quest 5 waxing the floor -->skip to 5min)
http://www.youtube.com/watch?v=VPa2ax02FJA

Is that a good way to solve this? Or is there a better, more efficient/clever way?
SMF spam blocked by CleanTalk