QBasic Animation Question(s)

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
timmychen
Newbie
Posts: 6
Joined: Thu Jan 10, 2008 2:21 pm

QBasic Animation Question(s)

Post by timmychen » Thu Jan 10, 2008 4:15 pm

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

Sinuvoid
Veteran
Posts: 155
Joined: Wed Jul 25, 2007 8:20 am

Post by Sinuvoid » Thu Jan 10, 2008 4:20 pm

Yeah its possible. But I dont know how to do it though :P And Welcome man!

User avatar
burger2227
Veteran
Posts: 2428
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Huh?

Post by burger2227 » Thu Jan 10, 2008 8:21 pm

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!
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0

User avatar
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Post by Nodtveidt » Thu Jan 10, 2008 10:13 pm

timmychen, your question isn't really all that clear...what exactly are you having problems with?

timmychen
Newbie
Posts: 6
Joined: Thu Jan 10, 2008 2:21 pm

Post by timmychen » Fri Jan 11, 2008 12:11 pm

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
Last edited by timmychen on Fri Jan 11, 2008 4:39 pm, edited 1 time in total.

Nemesis
Coder
Posts: 36
Joined: Mon Aug 16, 2004 12:54 pm
Location: Colorado Springs, Colorado

Post by Nemesis » Fri Jan 11, 2008 12:58 pm

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.

User avatar
burger2227
Veteran
Posts: 2428
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Movie?

Post by burger2227 » Fri Jan 11, 2008 4:47 pm

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
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0

timmychen
Newbie
Posts: 6
Joined: Thu Jan 10, 2008 2:21 pm

Post by timmychen » Fri Jan 11, 2008 9:20 pm

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.

nkk_kan
Veteran
Posts: 57
Joined: Thu Jun 01, 2006 10:45 am
Location: Gujrat,India,Asia
Contact:

Post by nkk_kan » Sat Jan 12, 2008 11:18 am

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~!

timmychen
Newbie
Posts: 6
Joined: Thu Jan 10, 2008 2:21 pm

Post by timmychen » Sat Jan 12, 2008 6:29 pm

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

nkk_kan
Veteran
Posts: 57
Joined: Thu Jun 01, 2006 10:45 am
Location: Gujrat,India,Asia
Contact:

Post by nkk_kan » Sun Jan 13, 2008 3:56 am

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!!

timmychen
Newbie
Posts: 6
Joined: Thu Jan 10, 2008 2:21 pm

Post by timmychen » Wed Jan 16, 2008 12:33 pm

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

nkk_kan
Veteran
Posts: 57
Joined: Thu Jun 01, 2006 10:45 am
Location: Gujrat,India,Asia
Contact:

Post by nkk_kan » Thu Jan 17, 2008 9:22 am

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..

User avatar
BadMrBox
Veteran
Posts: 86
Joined: Tue Feb 28, 2006 12:19 pm

Post by BadMrBox » Fri Jan 18, 2008 4:57 am

PP256 is for screen 13. Screen 7 only have 16 colors.

nkk_kan
Veteran
Posts: 57
Joined: Thu Jun 01, 2006 10:45 am
Location: Gujrat,India,Asia
Contact:

Post by nkk_kan » Fri Jan 18, 2008 2:59 pm

oh right ..sorry..my mistake >.< :oops:
pp256 - screen 13 - 256 colours

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

Nemesis
Coder
Posts: 36
Joined: Mon Aug 16, 2004 12:54 pm
Location: Colorado Springs, Colorado

Post by Nemesis » Sat Jan 19, 2008 1:35 pm

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.

timmychen
Newbie
Posts: 6
Joined: Thu Jan 10, 2008 2:21 pm

Post by timmychen » Thu Jan 24, 2008 9:48 pm

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. ;)

Sinuvoid
Veteran
Posts: 155
Joined: Wed Jul 25, 2007 8:20 am

Post by Sinuvoid » Thu Jan 24, 2008 9:52 pm

Thats great man!!! I could NEVER do that XD

User avatar
Stoves
Veteran
Posts: 101
Joined: Fri Feb 10, 2006 12:24 am
Location: Nashville, TN

Post by Stoves » Sat Feb 16, 2008 1:45 pm

Hahahaha... Cool animation! I spewed Mountain Dew through my nose when I saw SUPERCOOLSPECIALFRPMODE. Great job, timmychen!

Post Reply