Page 1 of 1

QBasic Animation Question(s)

Posted: Thu Jan 10, 2008 4:15 pm
by timmychen
Hey'all.

I'm new to this site, and pretty new to QBasic too. I recently wanted to make an animation. I know the basics of the GET, PUT, DATA statements, as well as setting up and using 1 and 2 dimensional arrays. As well as the usual non-graphics commands.

However, the animation is a different kind of animation - different in the sense that it doesn't follow a certain pattern - something you'd probably see on StickPage or something. It stays black and white and in the second dimension though.

Is this... possible? Actually, that's a bad word to use because technically anything (most things) are possible.. but.. like.. is there a way to do it without making each frame separately?

I had an assload of questions before, but I forgot them all. I'll edit this post (or include it in a later post when I respond) if I remember.

Thanks,
Timmy

Posted: Thu Jan 10, 2008 4:20 pm
by Sinuvoid
Yeah its possible. But I dont know how to do it though :P And Welcome man!

Huh?

Posted: Thu Jan 10, 2008 8:21 pm
by burger2227
I sure hope by the time you can remember, you explain it a LOT better!

I am losing interest already! What exactly do you want to move? If it involves graphics, you better read up. We are not teachers here!

Lee how do you know what is possible?

Still King!

Posted: Thu Jan 10, 2008 10:13 pm
by Nodtveidt
timmychen, your question isn't really all that clear...what exactly are you having problems with?

Posted: Fri Jan 11, 2008 12:11 pm
by timmychen
Oops, I guess I didn't explain it clearly enough. Haha, sorry. Was kinda out of it yesterday.

Yes, it involves graphics. No, I'm not looking for a teacher.

I want to make an animation. This animation is not a basic animation such as a ball bouncing around the screen. Actually, animation is a bad word. Let's call it a.. movie? Yeah. More like a movie - it has a storyline, moving people, stuff like that. So basically, what I want to know, can this be conveniently done?

I have a real question though. lol. Kind of a stupid one though.

Is there a number for uh.. transparent/nonexistent color? example:

two sprites:
-blue circle
-red square (larger than circle)

And say these are made using the DATA 00,00, blah blah method.

Would it be possible to put the blue circle on top of the red square, but have the red square be the background? It's obviously much more complex than this; it's just an example.

Thanks,
Timmy

Posted: Fri Jan 11, 2008 12:58 pm
by Nemesis
Ummm... it sounds like pretty simple stuff. You're just jumping too far ahead of yourself. You need to worry about the basic things you need to
implement first, before you can put it all together in one big picture, or ''movie'' (':lol:')
One of these basic things is sprite animation...
You simply need to animate a sprite or sprites that can
be displayed or 'PUT' transparently to the screen.
(Routines like this can be found in this sites d/l section.)
For the animation aspect, you can either use an algorithm
to move the sprite, or have it move via. a script.
Also you can animate your sprite like a cartoon animation
by showing different frames. (You can also find routines for
this in the d/l section and the tutorial section.)
If you need help just ask, but be more specific because the answers
to your questions will only get more specific!

Cya,

Nemesis.

Movie?

Posted: Fri Jan 11, 2008 4:47 pm
by burger2227
You might want to use page flipping in SCREEN 9 so that your screen does not flicker. Sreen 7 offers up to 7 pages. This sounds like it will not be a very easy thing to do if you don't know graphic basics yet.

Bob Seguin has a utility for frames called Animax. You will have to be artistic however.

Still King,

Ted

Posted: Fri Jan 11, 2008 9:20 pm
by timmychen
Thanks for the replies.

Well, I read through a couple tutorials, as well as this post.. and.. this is what I have so far. Lol, nothing big, just a sideways stick figure moving. diagonally down the screen.

Here's the code.

Code: Select all

DECLARE SUB PUT2 (Sprite() AS INTEGER, XSize AS INTEGER, YSize AS INTEGER, X AS INTEGER, Y AS INTEGER)
SCREEN 9, 0, 0, 1

DIM SHARED image%(11, 5)

FOR X = 0 TO 10
	FOR Y = 0 TO 4
		IF image% > 0 THEN
			READ image%(X, Y)
		END IF
	NEXT Y
NEXT X

DO
k$ = INKEY$
  CLS

  LINE (0, 0)-(150, 150), 1, BF

    PUT2 image%(), 11, 5, 10 + h, 10 + h

  PCOPY 0, 1
  h = h + 1
LOOP UNTIL k$ <> ""



DATA -1,04,04,04,-1
DATA -1,04,-1,04,-1
DATA -1,04,04,04,-1
DATA -1,04,04,04,-1
DATA -1,-1,04,-1,-1
DATA 04,04,04,04,04
DATA -1,-1,04,-1,-1
DATA -1,-1,04,-1,-1
DATA -1,04,04,04,-1
DATA -1,04,-1,04,-1
DATA -1,04,-1,04,-1

SUB PUT2 (Sprite() AS INTEGER, XSize AS INTEGER, YSize AS INTEGER, X AS INTEGER, Y AS INTEGER)
  FOR YP = 0 TO YSize - 1
    FOR XP = 0 TO XSize - 1
      PSET (X + XP, Y + YP), image%(XP, YP)
    NEXT XP
  NEXT YP
END SUB
Problem? Sprite comes up as a black rectangle.

I'm pretty sure this problem is a really simple one and probably caused by a silly mistake of mine. But I can't seem to catch it. D:

ADDED: It was working before I tried to make the -1's transparent.

Posted: Sat Jan 12, 2008 11:18 am
by nkk_kan
you need to mask it to hide that black colour surrounding the circle..

try this tut ...it helped me once..

http://www.petesqbsite.com/sections/tut ... tutor6.txt

and also check out

http://www.petesqbsite.com/sections/tut ... sign.shtml

happy coding~!

Posted: Sat Jan 12, 2008 6:29 pm
by timmychen
Woo! Thanks!

It works much better now. :D

Here's the code of the new one:

Code: Select all

DEFINT A-Z
DIM image%(25), pic%(25)
DIM imagemask%(25), picmask%(25)

SCREEN 9, 0, 0, 1

FOR x = 0 TO 4
  FOR y = 0 TO 4
    READ image%(i)
    PSET (x, y), image%(i)
    i = i + 1
  NEXT y
NEXT x

GET (0, 0)-(4, 4), pic%

i = 0
FOR x = 0 TO 4
  FOR y = 0 TO 4
    READ imagemask%(i)
    PSET (x, y), imagemask%(i)
    i = i + 1
  NEXT y
NEXT x

GET (0, 0)-(4, 4), picmask%

CLS

LINE (0, 0)-(100, 100), 14, BF
LINE (100, 100)-(200, 200), 1, BF

x = 5
y = 5

DO
  CLS
  LINE (0, 0)-(100, 100), 14, BF
  LINE (100, 100)-(200, 200), 1, BF
  k$ = INKEY$
  IF k$ <> "" THEN EXIT DO
  FOR g = 1 TO 25
    PUT (x, y), pic%, OR
    PUT (x, y), picmask%, AND
  NEXT g
  x = x + 1
  y = y + 1
  rounds = rounds + 1
  PCOPY 0, 1
LOOP UNTIL rounds = 300

DATA 04,00,04,00,04
DATA 00,00,04,00,00
DATA 04,04,04,04,04
DATA 00,00,04,00,00
DATA 04,00,04,00,04

DATA 04,15,04,15,04
DATA 15,15,04,15,15
DATA 04,04,04,04,04
DATA 15,15,04,15,15
DATA 04,15,04,15,04

Posted: Sun Jan 13, 2008 3:56 am
by nkk_kan
good dude ^_^

do you file manipulation?

store the data in a file and then read them...
you can create more number of frames without bloating ur program...

or maybe you can use BSV images..

check out "Bload" and "Bsave" commands in the help!!

Posted: Wed Jan 16, 2008 12:33 pm
by timmychen
Yep, got the bload and bsave down. ^^

Quick question though: How do I convert higher-level colors to screen 9 colors? I used PixelPlus to make a picture, then saved it as data. I only used the top row of colors (1-15), so the colors I picked should match up fine with screen 9 colors.

The data looks something like this:

Code: Select all

DATA 514,1536,1542,1542,1542,1542,1542,1798,0,0,0,0,0,0,0,0,0,0,514,514
DATA 0,512,514,2,1542,1542,1542,1542,1542,1542,7,0,0,0,0,0,0,0,0,0
DATA 512,514,0,512,522,2,1536,1542,1542,1542,1542,1542,1798,0,0,0,0,0,0,0
DATA 0,0,512,2570,2,512,2562,2,0,1542,1542,1542,1542,1542,1542,7,0,0,0,0
DATA 0,0,0,0,0,2562,2,512,514,1802,2316,1545,1542,1542,1542,1542,1542,1798,0,0
DATA 0,0,0,0,0,0,0,0,0,0,2304,1794,2313,3084,2310,1542,1542,1542,1542,1542
DATA 7,0,0,0,0,0,0,0,0,0,0,0,0,3072,3081,2311,2316,0,0,0

Posted: Thu Jan 17, 2008 9:22 am
by nkk_kan
err... i dunno about changing the colours and i don't understand the data..maybe someone else can explain it to you...but as far as i know Pp256(Pixel Plus) was designed to create images for screen 7 that is 255 colours and 320 x 200 screen mode..
but i think you should use screen 7 which is the fastest probably..though a bit small..

Posted: Fri Jan 18, 2008 4:57 am
by BadMrBox
PP256 is for screen 13. Screen 7 only have 16 colors.

Posted: Fri Jan 18, 2008 2:59 pm
by nkk_kan
oh right ..sorry..my mistake >.< :oops:
pp256 - screen 13 - 256 colours

haven't used Qb for a while.. :wink: :lol:

Posted: Sat Jan 19, 2008 1:35 pm
by Nemesis
timmychen wrote:Yep, got the bload and bsave down. ^^

Quick question though: How do I convert higher-level colors to screen 9 colors? I used PixelPlus to make a picture, then saved it as data. I only used the top row of colors (1-15), so the colors I picked should match up fine with screen 9 colors.

The data looks something like this:

Code: Select all

DATA 514,1536,1542,1542,1542,1542,1542,1798,0,0,0,0,0,0,0,0,0,0,514,514
DATA 0,512,514,2,1542,1542,1542,1542,1542,1542,7,0,0,0,0,0,0,0,0,0
DATA 512,514,0,512,522,2,1536,1542,1542,1542,1542,1542,1798,0,0,0,0,0,0,0
DATA 0,0,512,2570,2,512,2562,2,0,1542,1542,1542,1542,1542,1542,7,0,0,0,0
DATA 0,0,0,0,0,2562,2,512,514,1802,2316,1545,1542,1542,1542,1542,1542,1798,0,0
DATA 0,0,0,0,0,0,0,0,0,0,2304,1794,2313,3084,2310,1542,1542,1542,1542,1542
DATA 7,0,0,0,0,0,0,0,0,0,0,0,0,3072,3081,2311,2316,0,0,0
This data is in integer form.
So each number or integer can be reduced to its byte form
to extract the color, and position of the pixel.

Posted: Thu Jan 24, 2008 9:48 pm
by timmychen
Well, it's finished!

My modem broke down (it was making noises and started to smoke), so no internet for the past week. Heh. It did motivate me to hurry my ass up and finish the animation though. Nothing else to do other than games.

Anyways, here it is. Archived, it's only around 25 KB.

Clickity click!

The stuff at the end about the flying rainbow pony is just some silly stuff I put in. Some friends and I made an in-school Liero clan (yes, an in-school clan, that's how bored we were) named the Flying Rainbow Ponies - FRP. So, hope that explains it.

It's kinda short, not many variations, but it's a start. ;)

Posted: Thu Jan 24, 2008 9:52 pm
by Sinuvoid
Thats great man!!! I could NEVER do that XD

Posted: Sat Feb 16, 2008 1:45 pm
by Stoves
Hahahaha... Cool animation! I spewed Mountain Dew through my nose when I saw SUPERCOOLSPECIALFRPMODE. Great job, timmychen!