delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/20/18:17:01

From: James W Sager Iii <sager+@andrew.cmu.edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Allegro: rotate_sprite?
Date: Fri, 20 Mar 1998 15:22:45 -0500
Organization: Junior, MCS Undeclared, Carnegie Mellon, Pittsburgh, PA
Lines: 57
Message-ID: <kp4h0JW00WB=0eaEU0@andrew.cmu.edu>
NNTP-Posting-Host: po8.andrew.cmu.edu
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I had trouble using the allegro rotate_sprite command.
I wanted to make a program to help me paint images for my game.
My paint program lacks a rotation tool. I decided to code one up myself,
but I couldn't get the rotate command to work. Can you look through
my code, and see why the rotate command isn't working?
 
 
 
//my helper functions :)
#include "util1.h"
 
//Pass 3 arguments: File to be converted, Degrees to be rotated s1-359 ,
Final file name
void main(int argc, char *argv[])
{
//Bunch of fun variables :) 
int a,b,c,i;
char c3[30];
BITMAP *B,*C;
FILE *f1;

//catches if command line is done wrong
if(argc!=4)
{
cout<<"Rotate usage:"<<endl;
cout<<"Rotate <image.pcx> <number of degrees> <destination> "<<endl;
exit(0);
}
//inits allegro and all other fun stuff :)
 init();
//loads the bitmap to be rotated
//stndpal is a global pallete defined in util1.h
B=load_pcx(argv[1],stndpal);
//changes the string to an int
a=atoi(argv[2]);
//catches to see if the rotation value is in the legal range
if(a>359 || a<1)
{
cout<<"Rotate usage:"<<endl;
cout<<"Rotate <image.pcx> <1-359 degrees> <destination> "<<endl;
exit(0);
}
//Converts from polar to fixed point????
//I'm not sure what fixed point is
a=a*256;
a=a/360;
 
//Makes a bitmap large enough to hold B after rotation
//I think a diagonal is like 1.4  so to be safe I multiplied by 1.5
C=create_bitmap((B->w*150000)/100000,(B->h*150000)/100000);
//inits the bitmap
clear(C);
//The actual rotation step.
//It does nothing besides copy B onto C.
rotate_sprite(C,B,0,0,a);
save_pcx(argv[3],C,stndpal);
} 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019