Creating moving object on MicroView display


hi there everyone,
i want create moving spot (later group of pixels), follow given path. program controlled uno , display microoled sparkfun ( https://github.com/sparkfun/sparkfun_micro_oled_arduino_library ). managed create vertical or horizontal moving pixel code:

code: [select]
void verticalmov()       //pixel pixel movement of pixel:)
{
  (int y=19; y<29; y++)  //starts in position 19, finishes in position 29
  {
  oled.clear(page);              //clears displays buffer erase previous pixels
  oled.pixel(32,y);               //buffers of pixel fixed column in position 32
  oled.display();                  //prints pixel on display
  delay(200);                      //delay, control movement speed
  }
}



however in case of movement angle, have control 2 integers (x , y). , can't code below, because nested loop counting first x , y. realize answer may simple, not programmer, self teaching biologist:).

code: [select]
void anglemov()
{
  (int y=19; y<29; y++)     
    {
    (int x=35; x>30; x--)
      {
      oled.clear(page);
      oled.pixel(x,y);
      oled.display();
      delay(200); 
      }
    }
}


so questions are:
1. how incorporate 2 integers 1 loop?
2. how program such movements (both, horizontal , angled) not 1 pixel, set of couple pixels (like custom shape of i.e. 5 pixels).

this animation used animate artificial prey in behavioral studies.
thank in advance help.

not quite sure mean angled movement can this:
code: [select]


float x = 0;
float y = 0;
float dt = 0.01;
float moven = 1; // can change negative move left or positive move right


void mov(){
 x += moven * dt;
y += moven * dt;
}



i guess angled mean this:

code: [select]


float x = 0;
float y = 0;
float dt = 0.01;
float moven = 1; // can change negative move left or positive move right
float angle = 90;

void angledmove(){
x+= moven * math.cos(angle) * dt;
y += moven * math.sin(angle) * dt
}



you need execute angledmove method in loop.
in case oled.pixel() function doesn't take in floats have cast them doing this:

code: [select]


oled.pixel((int)x,(int)y);



Arduino Forum > Using Arduino > Programming Questions > Creating moving object on MicroView display


arduino

Comments

Popular posts from this blog

DHT11 Time out error using v0.4.1library

Sketch upload fails with Java error (___REMOVE___/bin/avrdude)!

Arduino Uno + KTY81/210 temperature sensor