gfxgfx
 
Please login or register.

Login with username, password and session length
 
gfx gfx
gfxgfx
 
Members, please note that our guidelines are located here.
 
gfx gfx
gfx
484583 Posts in 28410 Topics by 2464 Members - Latest Member: austinrobert May 27, 2020, 12:35:37 AM
*
gfx* Home | Help | Calendar | Login | Register | gfx
gfx
The Gaming Universe  |  The Archives  |  Archived Projects  |  Open Zelda  |  OZ Help (Moderator: red_team316)  |  Not sure of how to align this
gfx
gfxgfx
 

Author Topic: Not sure of how to align this  (Read 937 times)

Offline KingOfHumans

  • Messiah
  • ******
  • Posts: 17,866
    • View Profile
Not sure of how to align this
« on: March 28, 2011, 01:30:21 PM »
Code: [Select]
for(new n = iy - 52; n < y + 12; n+= 16)
PutSprite("e_spiderstring",x + 10,n,y + 40,0);
ix = initialX
iy = initialY
x = X
y = Y

I have a spider enemy that comes down from the ceiling when your near. In OOT when you hit the spider with a sword against it's mask, it hurts you. So in my game I have the spider swing away from the sword and then the opposite direction. So the spider will come back at you and hurt you. Every works for this part but I want the web line to draw better when moving east and west. If it moves east the line should look like this.
|
 |
  |
   |

Opposite for west. It will only swing 16 pixels so each web will only move 4 pixels at most unless if there's some major lag.
So the first web from the top should always use the IX, and the last web should use the X. Now how do I have the other two webs calculate the difference in between?
BTW each web is 16 pixels in height, 1 pixel in width(sprite is 8 pixels though)

Offline Khatuni

  • Executive
  • ***
  • Posts: 1,007
    • View Profile
Not sure of how to align this
« Reply #1 on: March 28, 2011, 03:01:05 PM »
So if the spider has swung completely to the right, the top web is still initialX and the bottom web is initialX + 16, right?
Then the x difference between each web should be 16/3. Or in other words:   (x - initialX)/3

But I have the feeling that's not what you mean...

Offline KingOfHumans

  • Messiah
  • ******
  • Posts: 17,866
    • View Profile
Re: Not sure of how to align this
« Reply #2 on: March 28, 2011, 05:37:25 PM »
But there's 4 webs, also your method doesn't quite work with the loop.

for(new n = iy - 52; n < y + 12; n+= 16)
         PutSprite("e_spiderstring",(x - ix)/3,n,y + 40,0); // this will draw all the web in a straight line.

Here's what it should look like aligned

|
|
|
|

Now when it moves 4 pixels to the east it should look like this
|
 |
  |
   |

here it is at 8 pixels
|
  |
    |
      |

now 16
|
    |
        |
            |

When it goes west it should go the opposite direction.
« Last Edit: March 28, 2011, 05:41:46 PM by KingOfHumans »

Offline Khatuni

  • Executive
  • ***
  • Posts: 1,007
    • View Profile
Not sure of how to align this
« Reply #3 on: March 28, 2011, 11:04:57 PM »
Try this:

for(new n; n < 4; n++)
    PutSprite("e_spiderstring", ix + (((x - ix)*n)/3), iy - 52 + (n*16), y + 40, 0);

When it comes to drawing sprites with a loop, I strongly prefer starting n at 0 and incrementing by 1.

Offline KingOfHumans

  • Messiah
  • ******
  • Posts: 17,866
    • View Profile
Re: Not sure of how to align this
« Reply #4 on: March 29, 2011, 06:03:35 PM »
Well yours was off by 10px. I had to adjust it a bit so it could work for north and south as well, but looks perfect now.
Thanks.

for(new n; n < (dir == north || dir == south ? 5 : 4); n++)
      {
         if(iy - 52 + (n*16) > y + 11)
            continue;
          PutSprite("e_spiderstring", ix + (((x - ix)*n)/3) + 10, iy - 52 + (n*16), y + 40, 0);
      }

Both north and south would make the web longer so it needed one more web in this case.
I'll show you what it looks like shortly.
« Last Edit: March 29, 2011, 06:05:31 PM by KingOfHumans »

The Gaming Universe  |  The Archives  |  Archived Projects  |  Open Zelda  |  OZ Help (Moderator: red_team316)  |  Not sure of how to align this
 

gfxgfx
gfx
SMF 2.0.17 | SMF © 2019, Simple Machines Page created in 0.187 seconds with 22 queries.
Helios Multi © Bloc
gfx
Powered by MySQL Powered by PHP Valid XHTML 1.0! Valid CSS!
anything