Author Topic: Ritchie's QB64 Sprite Library (updated V0.2 10/27/12)  (Read 11059 times)

TerryRitchie

  • Hero Member
  • *****
  • Posts: 2803
  • Press any key to continue or any other key to quit
Ritchie's QB64 Sprite Library (updated V0.2 10/27/12)
« on: August 05, 2011, 11:43:09 pm »
** The ZIP file now contains version 0.2 **
** The error handling routines were updated to report all errors in a pure text screen **

The documentation is finally finished and has been designed to be both a tutorial and reference to the library.  All of the example source code found in the tutorials is included as well, along with the sprite sheet and graphics used.  Also included is a copy of QB64Asteroids and QB64Invaders (both in their own ZIP file) to use as a learning aid as well.

Simply unzip the files into your QB64 folder and walk through the tutorials.  They should take you an hour or two to complete and well worth going through, in my humble opinion.

The sprite library is a series of commands I created to aid in game design, particularly with the managing of sprites.  The ZIP file in the link below is 1.26MB in size.

http://dl.dropbox.com/u/416997/SpriteLibrary.zip
« Last Edit: October 27, 2012, 08:31:29 pm by TerryRitchie »

Clippy

  • Hero Member
  • *****
  • Posts: 19259
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: Ritchie's QB64 Sprite Library
« Reply #1 on: August 06, 2011, 06:23:05 am »
Terry I have been meaning to ask, do you have a web site link to your tutorials and projects? I would like to add you to our Community section in the WIKI if that is OK with you. If you don't have a site perhaps we could set up some links to your works there.

Ted
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 SDL: QB64v0954-win15.7z

TerryRitchie

  • Hero Member
  • *****
  • Posts: 2803
  • Press any key to continue or any other key to quit
Re: Ritchie's QB64 Sprite Library
« Reply #2 on: August 06, 2011, 12:54:46 pm »
No, I sure don't have any site that I maintain tutorials or projects on. But I have for a while now been thinking of doing that.

I've owned ccnt1.com now for a few years with that goal in mind (the name of my class is CCNT1 Computer Communications and Networking Technologies). When school starts back up in a few weeks let me grab a senior that is looking for a senior project idea.  I'll have him/her build me a basic site framework to get started and then you can link to a tutorials and projects section I'll maintain on it.

Thanks Clippy!

Clippy

  • Hero Member
  • *****
  • Posts: 19259
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: Ritchie's QB64 Sprite Library
« Reply #3 on: August 06, 2011, 03:01:26 pm »
No problem. Let me know when you have something up.
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 SDL: QB64v0954-win15.7z

GarryRicketson

  • Guest
Re: Ritchie's QB64 Sprite Library
« Reply #4 on: August 07, 2011, 10:48:32 pm »
I just downloaded this, looks interesting,..and that sound like a good idea about a site,...if I can help in any way let me know,.
from Garry

DeeBee

  • Hero Member
  • *****
  • Posts: 507
    • Donnelly-House
Re: Ritchie's QB64 Sprite Library
« Reply #5 on: October 26, 2011, 12:44:09 pm »
I sent you an e-mail suggesting you prefix your identifiers
(variables, constants, types and functions/subs) with something
like "SPRLIB_" to avoid name conflicts.
(that's pretty common, and almost mandatory without OPTION EXPLICIT)

Also, what would it take to support alpha transparency for the sprites?

Clippy

  • Hero Member
  • *****
  • Posts: 19259
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: Ritchie's QB64 Sprite Library
« Reply #6 on: October 26, 2011, 12:50:20 pm »
DeeBee I suggest that YOU use OPTION_IMPLICIT_ to prefix yours!
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 SDL: QB64v0954-win15.7z

DeeBee

  • Hero Member
  • *****
  • Posts: 507
    • Donnelly-House
Re: Ritchie's QB64 Sprite Library
« Reply #7 on: October 26, 2011, 12:56:03 pm »
Now you're just being an assjack idiot.
You should be banned from this forum.

unseenmachine

  • Hero Member
  • *****
  • Posts: 3600
  • Make the Game not the ENGINE!!!
Re: Ritchie's QB64 Sprite Library
« Reply #8 on: October 26, 2011, 07:11:20 pm »
Quote
almost mandatory
LOL!! Thats impossible! But for subs/functions i sort of agree (GDK and VQB both use this method) but it's not really needed for types and i allways try to avoid constants when creating libs.

DeeBee

  • Hero Member
  • *****
  • Posts: 507
    • Donnelly-House
Re: Ritchie's QB64 Sprite Library
« Reply #9 on: October 26, 2011, 08:13:50 pm »
Quote
almost mandatory
{snip} But for subs/functions i sort of agree (GDK and VQB both use this method) but it's not really needed for types and i allways try to avoid constants when creating libs.

As long as they're prefixed, with a "sufficient" prefix, it should be fine and work well.
Constants are a good thing and can make code more readable, understandable, debuggable, etc.
TYPE declarations should be prefixed, but there is no need to prefix the variables
inside of them. (unless you want to type-prefix them like I do, which I always encourage)

Example in case I'm not being clear:

Code: [Select]
' Human Resource Development System

TYPE typeHRD_Person     ' or HRD_Person, although I think 'type' prefixing is important

   sName    AS STRING * 40
   nAge     AS INTEGER

END TYPE ' typeHRD_Person

DIM gtaPeople (1 to 100) AS typeHRD_Person

gtaPeople (1).sName = "John Doe"
gtaPeople (1).nAge = 33

Clippy

  • Hero Member
  • *****
  • Posts: 19259
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: Ritchie's QB64 Sprite Library
« Reply #10 on: October 26, 2011, 09:20:07 pm »
RULES, RULES, RULES! Some kind of Dicktater I think!
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 SDL: QB64v0954-win15.7z

DeeBee

  • Hero Member
  • *****
  • Posts: 507
    • Donnelly-House
Re: Ritchie's QB64 Sprite Library
« Reply #11 on: October 26, 2011, 11:12:53 pm »
I'm dressing up as Clippy for Halloween and scaring all the little kiddies.

p.s. It's good to be King.
« Last Edit: October 26, 2011, 11:18:01 pm by DeeBee »

TerryRitchie

  • Hero Member
  • *****
  • Posts: 2803
  • Press any key to continue or any other key to quit
Re: Ritchie's QB64 Sprite Library
« Reply #12 on: October 28, 2011, 12:53:09 pm »
I sent you an e-mail suggesting you prefix your identifiers
(variables, constants, types and functions/subs) with something
like "SPRLIB_" to avoid name conflicts.
(that's pretty common, and almost mandatory without OPTION EXPLICIT)

Also, what would it take to support alpha transparency for the sprites?


Got it and replied :)

codeguy

  • Hero Member
  • *****
  • Posts: 3829
  • what the h3ll did i name that code?
    • stuff at dkm
Re: Ritchie's QB64 Sprite Library
« Reply #13 on: January 17, 2012, 08:02:08 am »
RULES, RULES, RULES! Some kind of Dicktater I think!
clippy, you're ever the funny one ;D

SMcNeill

  • Moderator
  • Hero Member
  • *****
  • Posts: 5807
Re: Ritchie's QB64 Sprite Library
« Reply #14 on: July 15, 2012, 09:42:30 am »
I was looking at your library Terry, and I was wondering if there's a SpritePath command in there someplace that I missed?

SpriteTravel lets you move a sprite in X direction at S speed, but is there a command to set up a travel path for your sprites?

Something that work work like the following.   

Syntax would be like:
SpritePath routename$, route$, step
TravelRoute sprite%, routename$, speed%, repeat%

Use would be:
SpritePath GuardPatrol, "E300S300W300N300" , 1
TravelRoute GuardBob, GuardPatrol, 10,0

Then guard Bob would travel 300 (steps, clicks, pixels whatever you use.  For some games -- like Dragon Warrior/Final Fantasy/Pokemon  -- sprites move by tiles, not pixels) East, then 300 units South, 300 units West, 300 Units North, which would make a large square.   The travel speed would be 10, and repeat would tell us how many times the sprite should make such a movement...


Actually thinking about it a bit more, the whole concept could expand to an ActionCommand

T - Turn
M - Move
R - Right, L - left, U - up , D - Down, F - Forward, B - Backwards
S - Say
P - Pause
V - Visible
U - Unvisible
A - Activate Script
E - sound Effect
F - Finish Script
..... others added as the brain thinks of them.

Then you could create cut scenes and dialog for the sprites. 

ActionCommand BobsPatrol, "TR,P1,MF300,P1,TR,P1,MF300,P1,TR,P1,MF300,P1,TR,MF300,P1,S101,P3,TL,P1,TR,P1,TU,P1,TD,P1,S102,P3,TR,TL,TR,TL,TR,TL,S103,E12,P3,S104,TU,P1,F"

Then Bob would do all of the following:
(Turn Right,Pause a tick,Move Forward 300,Pause a tick) x 4 to walk a large square
Say dialog 101 "I wonder if anyone is watching?"
Pause 3 ticks
Turn left, Pause a Tick, Turn Right, Pause a Tick, Turn Up, Pause a tick, Turn Down, Pause a tick   (basically check to see if anyone is watching)
Say dialog 102 "I just feel like Dancing."
Pause 3 ticks
Turn Right, Turn Left, Turn Right, Turn Left, Turn Right, Turn Left  (some quick turns to simulate dancing)
Say dialog 103 "I would've made a good dancer."
Play Effect 12 "Sounds\sigh.wav"
Pause 3 ticks
Say dialog 104 "Oh well, back to work."
Turn Up
Pause 1 tick
Script is Finished.  If it's called with a repeater, it sets Bob up for a unique patrol path.   If it only happens once, it could be a cut-scene or so for our players, and followed by a E1,A12.  (Play Effect 1 "Sounds\fanfare.wav", Action 12 (Bob has joined the party!)

Seems like it'd take some work to incorporate, but it'd allow for scripting for RPG type games and not just games like Super Mario Brothers.
« Last Edit: July 15, 2012, 09:53:42 am by SMcNeill »
http://bit.ly/TextImage -- Library of QB64 code to manipulate text and images, as a BM library.

http://bit.ly/Color32 -- A set of color CONST for use in 32 bit mode, as a BI library.