<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'sprite roatation' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'sprite roatation' posted on the 'Pascal' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Wed, 19 Jun 2013 21:26:17 -0700</pubDate>
    <lastBuildDate>Wed, 19 Jun 2013 21:26:17 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>sprite roatation</title>
      <link>http://www.programmersheaven.com/mb/pasprog/87962/87962/sprite-roatation/</link>
      <description>i've made a tile based level with a top down view.  I have a sprite of a tank which can move up, down, left and right.  the only thing i can't figure out is how to rotate the tank easily.  I'm also looking for some sprite flipping/rotating routines if anyone has some.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/87962/87962/sprite-roatation/</guid>
      <pubDate>Fri, 23 Nov 2001 07:54:08 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: sprite roatation</title>
      <link>http://www.programmersheaven.com/mb/pasprog/87962/88263/re-sprite-roatation/#88263</link>
      <description>: i've made a tile based level with a top down view.  I have a sprite of a tank which can move up, down, left and right.  the only thing i can't figure out is how to rotate the tank easily.  I'm also looking for some sprite flipping/rotating routines if anyone has some.&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
All you need is to rotate by 90 degree? That's simple.&lt;br /&gt;
But let's first clarify few things:&lt;br /&gt;
Don't try to rotate sprite while game is in progress.&lt;br /&gt;
Make sure that you create 4 versions of the sprite&lt;br /&gt;
while loading or initializing game. Everything else&lt;br /&gt;
is not efficient and will slow your game down.&lt;br /&gt;
&lt;br /&gt;
Now let's go back to sprite rotation:&lt;br /&gt;
The sprites are normally stored in arrays of bytes.&lt;br /&gt;
If H and W are height and width of the sprite,&lt;br /&gt;
the array size is H*W. So all you have to do is&lt;br /&gt;
read one sprite horizontally and write to another&lt;br /&gt;
vertically. If the H and W are not the same, make sure&lt;br /&gt;
your target sprite can hold the data. &lt;br /&gt;
If H and W are the same, thins are even simpler: &lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;

var spr1,spr2,... :array[1..H*H] of byte;  { H and W are same }
    i,j,k,l:byte;

;
;
;

{ let's assume Spr1 is the sprite w want to rotate.
  the rotated image will be stored into Spr2 }

  for i:=1 to H do
    for j:=1 to H do
      begin
        k:=i+j*H;
        l:=j+i*H;
        spr1[k]:=spr2[l];
      end;

&lt;/pre&gt;  &lt;br /&gt;
&lt;br /&gt;
Iby&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/87962/88263/re-sprite-roatation/#88263</guid>
      <pubDate>Sun, 25 Nov 2001 20:42:07 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: sprite roatation</title>
      <link>http://www.programmersheaven.com/mb/pasprog/87962/88264/re-sprite-roatation/#88264</link>
      <description>&lt;pre class="sourcecode"&gt;

Eh... typo... &lt;img src="http://www.programmersheaven.com/images/Community/twink.gif" width="15" height="15" alt="" /&gt;

: 
: { let's assume &lt;strong&gt;Spr2&lt;/strong&gt; is the sprite w want to rotate.
:   the rotated image will be stored into Spr1 }
: 
&lt;/pre&gt;  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Iby&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/87962/88264/re-sprite-roatation/#88264</guid>
      <pubDate>Sun, 25 Nov 2001 20:44:00 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: sprite roatation</title>
      <link>http://www.programmersheaven.com/mb/pasprog/87962/88316/re-sprite-roatation/#88316</link>
      <description>ok, how do i use this to put the rotated tile on the screen (i'm using puttile(x,y,name,where) ) would i just use the new array with the rotated tile in it as name?&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/87962/88316/re-sprite-roatation/#88316</guid>
      <pubDate>Mon, 26 Nov 2001 07:01:52 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: sprite roatation</title>
      <link>http://www.programmersheaven.com/mb/pasprog/87962/88412/re-sprite-roatation/#88412</link>
      <description>: ok, how do i use this to put the rotated tile on the screen (i'm using puttile(x,y,name,where) ) would i just use the new array with the rotated tile in it as name?&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
You got it...&lt;br /&gt;
&lt;br /&gt;
Iby&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/87962/88412/re-sprite-roatation/#88412</guid>
      <pubDate>Mon, 26 Nov 2001 18:40:44 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: sprite roatation</title>
      <link>http://www.programmersheaven.com/mb/pasprog/87962/88525/re-sprite-roatation/#88525</link>
      <description>ok, i understand the code but i'm having some trouble.  In the example you used &lt;br /&gt;
&lt;br /&gt;
var spr1,spr2 : array etc etc&lt;br /&gt;
&lt;br /&gt;
the thing is, i'm using something similar to this to handle my sprites:&lt;br /&gt;
&lt;br /&gt;
type spr1 = array [1..20*20] of byte  &lt;br /&gt;
&lt;br /&gt;
and then doing this to draw the sprite:&lt;br /&gt;
&lt;br /&gt;
const floor : spr1 = (&lt;br /&gt;
0,0,0,0,1,0,2,0,2,0,0,&lt;br /&gt;
0,1,0,2,0,2,0,2,0,1,0, etc etc&lt;br /&gt;
&lt;br /&gt;
when i try and implement the code you suggested with this array, it wont let me.  how do i get around this?&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/87962/88525/re-sprite-roatation/#88525</guid>
      <pubDate>Tue, 27 Nov 2001 08:04:21 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: sprite roatation</title>
      <link>http://www.programmersheaven.com/mb/pasprog/87962/88546/re-sprite-roatation/#88546</link>
      <description>: ok, i understand the code but i'm having some trouble.  In the example you used &lt;br /&gt;
: &lt;br /&gt;
: var spr1,spr2 : array etc etc&lt;br /&gt;
: &lt;br /&gt;
: the thing is, i'm using something similar to this to handle my sprites:&lt;br /&gt;
: &lt;br /&gt;
: type spr1 = array [1..20*20] of byte  &lt;br /&gt;
: &lt;br /&gt;
: and then doing this to draw the sprite:&lt;br /&gt;
: &lt;br /&gt;
: const floor : spr1 = (&lt;br /&gt;
: 0,0,0,0,1,0,2,0,2,0,0,&lt;br /&gt;
: 0,1,0,2,0,2,0,2,0,1,0, etc etc&lt;br /&gt;
: &lt;br /&gt;
: when i try and implement the code you suggested with this array, it wont let me.  how do i get around this?&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
type spr=array[1..9] of byte;

const flor:spr=(1,2,3,
                4,5,6,
                7,8,9);

var i,j,k,l:byte;
    flok:spr;

begin
  for i:=1 to 3 do
    for j:=1 to 3 do
      begin
        k:=(i-1)*3+j;
        l:=i+(j-1)*3;
        flok[k]:=flor[l];
      end;
end.
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Use Watch to check the content of FLOR and FLOK variables&lt;br /&gt;
after rotation...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Iby&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/87962/88546/re-sprite-roatation/#88546</guid>
      <pubDate>Tue, 27 Nov 2001 10:33:49 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: sprite roatation</title>
      <link>http://www.programmersheaven.com/mb/pasprog/87962/88737/re-sprite-roatation/#88737</link>
      <description>ok, it's working - sort of - it puts some sort of image on the screen! it takes the original image and messes it up a bit :( &lt;br /&gt;
&lt;br /&gt;
I understand the theory, i need to read my sprite array from left colom to right colom instead of top row to bottom row.  i just can't implement it!!! could you take a look at my code for me and have a mess around please?&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/87962/88737/re-sprite-roatation/#88737</guid>
      <pubDate>Wed, 28 Nov 2001 06:02:11 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: sprite roatation</title>
      <link>http://www.programmersheaven.com/mb/pasprog/87962/88774/re-sprite-roatation/#88774</link>
      <description>: ok, it's working - sort of - it puts some sort of image on the screen! it takes the original image and messes it up a bit :( &lt;br /&gt;
:&lt;br /&gt;
: I understand the theory, i need to read my sprite array from left colom to right colom instead of top row to bottom row.  i just can't implement it!!! could you take a look at my code for me and have a mess around please?&lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
Hmmm.... If I understand it correctly you are&lt;br /&gt;
trying to modify your "put_sprite" routine...&lt;br /&gt;
That's of course possible but not recommended.&lt;br /&gt;
It's better to keep it as it is (keep it general)&lt;br /&gt;
and just rotate image. Send me the full source&lt;br /&gt;
and I will take a good look at it. I have somewhere&lt;br /&gt;
code for my sprite editor with sample sprites.&lt;br /&gt;
It is old and if I had to redo it, I would probably&lt;br /&gt;
change few things. But it works quite nice and&lt;br /&gt;
I am sort of lazy &lt;img src="http://www.programmersheaven.com/images/Community/smile.gif" width="15" height="15" alt="" /&gt;. If you want I could&lt;br /&gt;
email it to you.&lt;br /&gt;
&lt;br /&gt;
Iby&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/87962/88774/re-sprite-roatation/#88774</guid>
      <pubDate>Wed, 28 Nov 2001 10:33:37 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: sprite roatation</title>
      <link>http://www.programmersheaven.com/mb/pasprog/87962/89966/re-sprite-roatation/#89966</link>
      <description>Hello!&lt;br /&gt;
I was just surfing around at sourceforge and ran across something that might help...&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://sourceforge.net/projects/burn/"&gt;http://sourceforge.net/projects/burn/&lt;/a&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/87962/89966/re-sprite-roatation/#89966</guid>
      <pubDate>Thu, 06 Dec 2001 01:43:58 -0700</pubDate>
      <category>Pascal</category>
    </item>
  </channel>
</rss>