EASy68K  
It is currently Sun Dec 16, 2018 10:39 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: animate
PostPosted: Sat Nov 20, 2010 2:45 pm 
Offline

Joined: Sat Nov 20, 2010 2:26 am
Posts: 2
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


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 21, 2010 12:58 am 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1087
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.

_________________
Prof. Kelly


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 21, 2010 7:29 am 
Offline

Joined: Sat Nov 20, 2010 2:26 am
Posts: 2
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


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 21, 2010 1:48 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1087
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

_________________
Prof. Kelly


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group