Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

need help on how to make random animation from this allegro

animation

  • Please log in to reply
2 replies to this topic

#1 MyRedz

MyRedz

    CC Lurker

  • Just Joined
  • Pip
  • 5 posts

Posted 25 March 2009 - 03:52 AM

hello i am unstuck at this question because i dont know how to call it..and random animation is something confusing here
here's my question
and here's my coding.
i am unstuck on how to do random animate.
from animation.cpp i got transx,transy,transxy,transpxny.
but now i dunno how to use the ScreenSaver(Screen& Shape* shps[]) which it wants to pass shapes into which is in this case i made a house..and what to do inside the void ScreenSaver(Screen& Shape* shps[])?the escape function i declared inside the void screensaver earlier alreadi.

#include <allegro.h>
#include "House.h"
#include "ExampleColors.h"
#include "HelperFunctions.h"

//----Set Screen Resolution
ust XRES = 1024; 
ust YRES = 600;
//----Set house center-------
Point* houseCenter = new Point(900,450);

//---Make 2 homes-------------
House* h = new House(houseCenter, new Point(150,150), WHITE, BLUE, 30,30,15,15);
//--------------------------
void ScreenSaver(Screen& Shape* shps[]);
int main(){
Screen scr(*BLACK, XRES,YRES); //Initialize screen
//Color* backCol = scr.getBg(); //create a variable to store background color
allegro_init();//Allegro initialization
install_keyboard();//Set up for keyboard input

//Set the graphics mode to a 320x240-pixel window.
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320,240,0,0);
h->draw(scr);
ScreenSaver(scr& House*h[]);
///TransX( scr, h, h, -100,3,1);//moving house in x direction for -100 value
//TransXY( scr, h, h, -100,3,1)///moving house in x and y direction
//TransY( scr, h, h, -100,3,1)//moving house in y direction
//TransPXNY( scr, h, h, -100,3,1)//move house in +x and-y direction
//scr.refresh();
//scr.wait(6000); //wait for 6 seconds
//can also use system("pause") here instead;
return 0;

} 
void ScreenSaver(Screen& House*h[])
{

int i;
while(!key[KEY_ESC]){//loop until user presses Esc key

clear_keybuf();
rest(10);
for(i=0;i<i-1;i++)
{
i++;
TransX( scr, h, h, i,3,1);
}

return (0);
}
END_OF_MAIN();
#include <allegro.h>
#include "House.h"
#include "ExampleColors.h"
#include "HelperFunctions.h"

//----Set Screen Resolution
ust XRES = 1024; 
ust YRES = 600;
//----Set house center-------
Point* houseCenter = new Point(900,450);

//---Make 2 homes-------------
House* h = new House(houseCenter, new Point(150,150), WHITE, BLUE, 30,30,15,15);
//--------------------------
void ScreenSaver(Screen& Shape* shps[]);
int main(){
Screen scr(*BLACK, XRES,YRES); //Initialize screen
//Color* backCol = scr.getBg(); //create a variable to store background color
allegro_init();//Allegro initialization
install_keyboard();//Set up for keyboard input

//Set the graphics mode to a 320x240-pixel window.
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320,240,0,0);
h->draw(scr);
ScreenSaver(scr& House*h[]);
///TransX( scr, h, h, -100,3,1);//moving house in x direction for -100 value
//TransXY( scr, h, h, -100,3,1)///moving house in x and y direction
//TransY( scr, h, h, -100,3,1)//moving house in y direction
//TransPXNY( scr, h, h, -100,3,1)//move house in +x and-y direction
//scr.refresh();
//scr.wait(6000); //wait for 6 seconds
//can also use system("pause") here instead;
return 0;

} 
void ScreenSaver(Screen& House*h[])
{

int i;
while(!key[KEY_ESC]){//loop until user presses Esc key

clear_keybuf();
rest(10);
for(i=0;i<i-1;i++)
{
i++;
TransX( scr, h, h, i,3,1);
}

return (0);
}
END_OF_MAIN();
#include <allegro.h>
#include "House.h"
#include "ExampleColors.h"
#include "HelperFunctions.h"

//----Set Screen Resolution
ust XRES = 1024; 
ust YRES = 600;
//----Set house center-------
Point* houseCenter = new Point(900,450);

//---Make 2 homes-------------
House* h = new House(houseCenter, new Point(150,150), WHITE, BLUE, 30,30,15,15);
//--------------------------
void ScreenSaver(Screen& Shape* shps[]);
int main(){
Screen scr(*BLACK, XRES,YRES); //Initialize screen
//Color* backCol = scr.getBg(); //create a variable to store background color
allegro_init();//Allegro initialization
install_keyboard();//Set up for keyboard input

//Set the graphics mode to a 320x240-pixel window.
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320,240,0,0);
h->draw(scr);
ScreenSaver(scr& House*h[]);
///TransX( scr, h, h, -100,3,1);//moving house in x direction for -100 value
//TransXY( scr, h, h, -100,3,1)///moving house in x and y direction
//TransY( scr, h, h, -100,3,1)//moving house in y direction
//TransPXNY( scr, h, h, -100,3,1)//move house in +x and-y direction
//scr.refresh();
//scr.wait(6000); //wait for 6 seconds
//can also use system("pause") here instead;
return 0;

} 
void ScreenSaver(Screen& House*h[])
{

int i;
while(!key[KEY_ESC]){//loop until user presses Esc key

clear_keybuf();
rest(10);
for(i=0;i<i-1;i++)
{
i++;
TransX( scr, h, h, i,3,1);
}

return (0);
}



Edited by WingedPanther, 25 March 2009 - 07:34 AM.
finish code tags

  • 0

#2 Aereshaa

Aereshaa

    CC Devotee

  • Just Joined
  • PipPipPipPipPipPip
  • 638 posts

Posted 25 March 2009 - 08:27 AM

You defined three functions with the name ScreenSaver(). You can't do that in C, because C doesn't support selection by arguments.
  • 0
Watches: Nanoha, Haruhi, AzuDai. Listens to: E-Type, Dj Melodie, Nightcore.
"When people are wrong they need to be corrected. And then when they can't accept it, an argument ensues." - MeTh0Dz

#3 MyRedz

MyRedz

    CC Lurker

  • Just Joined
  • Pip
  • 5 posts

Posted 25 March 2009 - 10:21 PM

but now i use c++ and this is supposely is OOP in c++.
i use allegro library which is meant for making 2d animations is it?
so how to define the arguments in void ScreenSaver(Screen& Shape* shps[])?
because my question specifically needs this..
it says

Make a function void ScreenSaver(Screen& Shape* shps[], Shape* masks[]) in which you take an array of shape pointers and their masks, and randomly animate all these shapes. You are required to pass only the shapes you made before (car, and houses) and animate them, you need not worry about shapes colliding or overdrawing each other. The screen saver should keep going until the user presses the escape key.

the escape key i know how to do it..
now can u tell me what to define argument in the function Screensaver?
is it ScreenSaver(scr& House*h[])??
because now i only declare house as a object then.so to random animate it i guess.
  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download