BBC BASIC for Windows
Programming >> Graphics and Games >> The Puppet Master idea
http://bb4w.conforums.com/index.cgi?board=graphics&action=display&num=1462255800

The Puppet Master idea
Post by michael on May 3rd, 2016, 06:10am

This is just a show of the idea.
Why have a huge data base that tells an object where it must go?
If you are animating an image, it would be nice to control the destination with few coordinates. This is a proof of concept.
So say you wanted something to revolve around some other object( perhaps a planet or moon for a game), you could use data coordinates to tell where the object must go and the program would move it gradually to that location.

I plan to use this idea for toon animation. So I will need many variables for each body part and they will need their own data sets for each specific movement.
Each body part would have to be monitored and moved in each frame so it looked smooth and realistic.

I will make a tool for this eventually.

Code:
    
  REM SET MODE TO 8 USING VDU
      VDU 22,8
      REM SET LINE THICKNESS TO 3
      VDU 23,23,3|
      xx%=0:yy%=0:h%=100:v%=100:sw%=0:s%=0
      continue$="":pass%=0
      f$=""
      REM OFF
      GCOL 1
      REPEAT
        DATA 800,800,100,300,800,500,3000,3000
        READ h%,v%
        IF h%=3000 THEN RESTORE:READ h%,v%:f$="NO"
        REPEAT
          IF xx%<h% THEN xx%=xx%+1
          IF yy%<v% THEN yy%=yy%+1
          IF xx%>h% THEN xx%=xx%-1
          IF yy%>v% THEN yy%=yy%-1
          CLG
          * REFRESH OFF
          CIRCLE FILL xx%,yy%,100
          MOVE 100,100:PRINT xx%
          MOVE 100,70:PRINT yy%
          * REFRESH
          IF xx%=h% THEN s%=1
          IF yy%=v% THEN sw%=1
          IF sw%=1 AND s%=1 THEN pass%=1
        UNTIL pass%=1
        pass%=0:s%=0:sw%=0
      UNTIL continue$="done"
      END
 

Re: The Puppet Master idea
Post by DDRM on May 3rd, 2016, 08:38am

Hi Michael,

Not sure what you mean by having a huge database to tell the object where to go, but this kind of code is a fairly standard approach.

You could consider wrapping up some of your variables relating to the movement and target position of the object as a structure - that might be helpful when you have multiple objects: for example:

DIM MyObject{px,py,tx,ty,v}

where px and py, and tx and ty, are the current and target positions, respectively, and v is the velocity.

Then you could have an array of structures:

DIM AllObjects{(50)}= MyObject{}

...so that you can handle them all in a loop.

A cartoon figure would pose some extra challenges: the upper arm "top" would presumably have to take its position from the top of the trunk, while the elbow could move - and the forearm would have to take that point as it's start, etc. Modelling a compound pendulum might be a simple starting place for trying that!

Can you amend your code to avoid the abrupt changes at the crossover points? (Hint: what happens if you move, say, 10% of the way to the next point? You'll need some boundary conditions, too).

Incidentally, your MOVE - PRINT instructions aren't working, since you haven't set VDU 5 - it's just most are being hidden by the CLG! You could consider PRINT TAB(x,y) rather than trying to tie PRINTs to the graphics cursor.

Best wishes,

D

Re: The Puppet Master idea
Post by michael on May 3rd, 2016, 09:33am

Yeah, I left those print statements in the program after I finally cleared up the issues. It was just left over test code.
This was just an simple example.
But I really want to get the cartoon idea working, as I need reusable images to make my animation smooth.
And I have another YouTube video planned with a good show, and I really want my animations to work like puppets on screen.. (that's what the data base would be for.)

Animation subroutines.

I also considered your idea of quick moves.. So say the toon wants to move its legs faster or say a mouth animation would move faster.. Or say the whole toon falls back or collides..

My solution would be a speed increase until limits were reached for destination. So there would always be a buffer zone.

And the cartoon images will be 2D simple.. (but well designed)

I will post the tool for animation later.. This is just a part of the player idea.