EASy68K
http://www.easy68k.com/EASy68Kforum/

animate
http://www.easy68k.com/EASy68Kforum/viewtopic.php?f=6&t=943
Page 1 of 1

Author:  anisfariza2010 [ Sat Nov 20, 2010 2:45 pm ]
Post subject:  animate

Hi,

i'm was asked to draw a graphic in ASCII code, then have to make the graphic animate.....i'm not sure how to program it because i'm new to programming.....can anyone guide me how to make the display animate?

Thanks

Author:  profkelly [ Sun Nov 21, 2010 12:58 am ]
Post subject: 

When you say graphic in ASCII do you mean text? Usually graphics are done by drawing pixels. In any event, animation is performed by drawing the image, calculating a new position for the image, erasing the old image and drawing in the new position. If this is done fast enough in a loop the image will appear to move on the screen.

Author:  anisfariza2010 [ Sun Nov 21, 2010 7:29 am ]
Post subject: 

profkelly wrote:
When you say graphic in ASCII do you mean text? Usually graphics are done by drawing pixels. In any event, animation is performed by drawing the image, calculating a new position for the image, erasing the old image and drawing in the new position. If this is done fast enough in a loop the image will appear to move on the screen.


ya, text. how to calculate a new position for the image? Would you mind to show me some example?

Thanks

Author:  profkelly [ Sun Nov 21, 2010 1:48 pm ]
Post subject: 

Here is a modification of the bouncing ball code from the examples page.

Code:
*-----------------------------------------------------------
* Program Number: v1.0
* Written by    : Chuck Kelly
* Date Created  : Nov-21-2010
* Description   : Bouncing Text
* Bounces '@' character.
*-----------------------------------------------------------
    ORG     $1000

DIAMETER EQU    10
FLOOR   EQU     440
MAX_X   EQU     639-DIAMETER
MAX_Y   EQU     FLOOR-DIAMETER

START
    move.l  #8,d5               deltaX
    move.l  #1,d6               deltaY

loop
    move.l  X1,d1               X1
    move.l  Y1,d2               Y1

    add.l   d5,d1               X1 += dX
    if <mi> then.s              if hit left edge of screen
        clr.l   d1                  X1 = 0
        neg.l   d5                  -deltaX
    endi
    if.l d1 <hs> #MAX_X then.s  if hit right edge of screen
        move.l  #MAX_X,d1           X1 = MAX_X
        neg.l   d5                  -deltaX
    endi

    add.l   d6,d2               Y1 += dY
    if <mi> then.s              if hit ceiling
        clr.l   d2                  Y1 = 0
        neg.l   d6                  -deltaY
    endi
    if.l d2 <hs> #MAX_Y then.s  if hit floor
        move.l  #MAX_Y,d2           Y1 = MAX_Y
        sub.l   #3,d6               remove some energy
        if <mi> then.s              if bouncing stopped
            move.l  #15,d2              restart
            move.l  #1,d6               deltaY = 1;
        else
            neg.l   d6                  -deltaY (bounce off floor)
        endi
    endi
    move.l  d1,X1               save new position
    move.l  d2,Y1

    lea     text,a1
    move.b  #95,d0              trap task #95 draws text at x,y
    trap    #15                 draw text

    move.b  #23,d0              delay for 3/100 sec (33 fps)
    move.l  #3,d1
    trap    #15
   
    add.l   #1,d6               gravity

    bra     loop   ***** INFINITE LOOP *****

    STOP   #$2000

X1      DC.L    20     
Y1      DC.L    15     
text    DC.B    '@',0

    END     START

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/