Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 Sprites - Is There Another Way?
Index -> Programming, Turing -> Turing Tutorials
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message

PostPosted: Fri Mar 18, 2005 10:31 am   Post subject: Sprites - Is There Another Way?

Sprites - A Tutorial for a New Way

Ok, here we go... as you may know, or just found out and looking for a reason why, Sprites in Turing v4.x have been disabled. They won't work. There are however alternatives to the default Sprite module, such as DanSprite. DanSprite was made by Hacker Dan, an Admin and the Owner I believe of As you may know if you've tried DanSprite is that it has some bugs... In fact it has quite a few bugs. Dan gives the explanation for this:
Hacker Dan wrote:
Ok the truth about dansprits is that in all hosntly they suck, i made them when i was very borad one night. But they are all that u have if u whont to use sprites in turing (well there may be one by another user on the forum i whould have to check). They work ok in some cases but b/c i whonted them to be useable by baick users i made it to simple and it caused some unforseen bugs.
I encountered these bugs in DanSprite when I tried to start a RPG of my own, and then went on a rampage to create a more bug-free solution. Well I came up with BacchusSprite (Don't you just love my originality?). BacchusSprite is very similar to DanSprite and infact I used DanSprite as a guide when I got stuck every now and then. One difference is that every problem I have encountered has been fixed and hopefully should now work almost flawlessly.

The Commands

The New function is used to assign a Sprite to an Integer variable so that it can then be refered back to and moved around with that variable. ie: like Pic.FileNew
The Move procedure is used to move the Sprite around the screen. It will move the Sprite from it previous location to the specified x and y
The Change procedure is used to Change the existing Sprite to a new Picture.
The Free procedure is used to free a Sprite and to just save space. ie: like Pic.Free
The Update procedure is used to redraw the specified Sprite above others
The UpdateAll procedure is to completly redraw all Sprites, starts and the first created
The ColorBack procedure is to set the Transparent Color of the Sprite, default setting is white (0)
The Mirror procedure is used to Mirror the Sprite; flip the Sprite Horizontally
The Flip procedure is used to Flip the Sprite; flip the Sprite Vertically
The Rotate procedure is used to rotate the Sprite to a desired angle, the Rotation point is specified by the rotatex and rotatey. ie:similar to Pic.Rotate
the Mode procedure is used to specify the desired Picture mode for the Sprite (use like a normal Picture, picCopy, picXor, picMerge), default setting is picMerge *Thxs Cervantes
the Height function returns the value in Pixels that the Height of the Sprite is
the Width function returns the value in Pixels that the Width of the Sprite is

Lastly, I have also included an example of BacchusSprite in the form of Zero (from Megaman) running around. Some may remember this as a .exe that I poasted before, there are bugs, and I probably sould have written it better. But it is only an Example.
Left->Left Arror
Right->Right Arrow
Jump->Up Arrow (can jump twice)
Z-Sword-> c (can slice 3 times, buggy though)

Hope they Help you out with whatever you're doing.


*For BSprite.tu file, use the one poasted by Cervantes after this post

PostPosted: Sat Mar 19, 2005 8:45 am   Post subject: (No subject)

Nice Bacchus. Very well done. I have one minor improvement, though. Smile Instead of making mode a string, make it an int. That way, people can type in "picMerge" (withouth the "s) or "picCopy" or "picXor", just as they would for a normal picture. They don't have to get used to the new method. But, more importantly then that (which doesn't really matter) is you save yourself lines. Instead of having a if .. elsif .. elsif .. end if everytime you want to draw something (for the various modes) just do this:

Pic.Draw (sprite (picID).pic, sprite (picID).x, sprite (picID).y, sprite (picID).mode)

sprite (picID).mode should be either 0, 1, or 2. 0 = picCopy. 1 = picXor. 2 = picMerge.

put picMerge
put picCopy
put picXor

Thanks for the submission Bacchus! +50 BITS

With the mode modification

 Filename:  BSprite.tu
 Filesize:  8.84 KB
 Downloaded:  698 Time(s)


PostPosted: Sat Mar 19, 2005 11:53 am   Post subject: (No subject)

ic, i wasnt to sure about that b4 and i didnt test it as much, thxs

PostPosted: Thu Apr 14, 2005 7:31 pm   Post subject: (No subject)

Ok i got a question for you ummmm yeah which is better Bacchus Sprites or DanSprite i tried both and i like Bacchus but whats the difference?

PostPosted: Tue Apr 19, 2005 12:44 pm   Post subject: (No subject)

Ummm...I hate to be a nitpicker, but is there any chance you could repost the exemplar with Zero in it?
I could really use it to help me out.
Y'see, I'm trying to recreate the Special Stage from Sonic the Hedgehog 2 for a Grade 12 CompSci project...and right now it's stinking.
And if I could use BSprite and the accompanying example, I could make my project that much better.

PostPosted: Tue Apr 19, 2005 7:37 pm   Post subject: (No subject)

oops srry i havent checked this in a bit lol. ok the difference between DanSprite and BacchusSprite (arnt i so original with that name Razz) is if you try having a sprite go outside the window. in DanSprite it will leave a bit left over. BacchusSprite also has a check for if you draw a Sprite over another, it will still get the background. then just a few other things that i cant remember lol mostly preference for me (some of DanSprites command typos bugged me and i liked shorter command names). sure ill try posting the example again (i may have to clear some space i need more then 2 mb Sad )
Zero Example

 Filesize:  608.49 KB
 Downloaded:  608 Time(s)

Mr. T

PostPosted: Mon Jun 27, 2005 8:40 pm   Post subject: Alex's Opinion

BSprite.ColorBack(spriteID,color:int) doesnt seem to change the pic's background colour.

PostPosted: Mon Jun 27, 2005 8:42 pm   Post subject: (No subject)

I've never used BSprite, but it might just be treating the specified colour as the sprites background, not changing it.

PostPosted: Mon Jun 27, 2005 10:47 pm   Post subject: (No subject)

Yes, thats correct. Its to set the trasperent color for the sprite.
Mr. T

PostPosted: Mon Jun 27, 2005 11:08 pm   Post subject: Alex's Opinion

Can u explain how to do collision detection with sprites?

PostPosted: Mon Jun 27, 2005 11:40 pm   Post subject: (No subject)

Depends on how your doing your game. Side-camera View, Overhead-Camera View, etc.
For an overhead-camera view you would probably have tiles and a text file for the collision (accually I'm working on something like that atm)
For a side-camera view, you would most likely use x/y comparison.
Mr. T

PostPosted: Mon Jun 27, 2005 11:50 pm   Post subject: Alex's Opinion

is it a good idea (or even possible) to use whatdotcolour for this kind of collision?

PostPosted: Wed Jun 29, 2005 6:17 am   Post subject: (No subject)

It probably won't be that good of an idea to use whatdotcolor with sprites because most sprites are pictures with many different colors in them. There is a way of collision detection where you draw the color of everything before the main view and use that to detect the collision, but that would makes your program go slower and in my oppinion is unnecissary because I belive that x/y comparison would work better.

PostPosted: Thu Jun 30, 2005 1:16 am   Post subject: (No subject)

But I would warn you against using x/y comparison. It's really painful if you have a lot of obstacles. It could maybe work for a snake game, but something like a basic mario style game would require a lot of defining. One alternative way is just doing it using a grid system. Make small boxes if you need them, but its a pretty good way.

PostPosted: Sat Oct 21, 2006 3:14 pm   Post subject: Huh?

Ok, I know this topic is more than a year old and I probably won't get a reply, but I need help Sad

It doesn't work for me...

It draws the first sprites but then when i try to move them it pops up the BSprite.tu code window and displays the error of Process "sprite_draw": Pic was freed.

sprite_draw is the name of the process I have it looks like this:

process sprite_draw
end sprite_draw

I don't know why this happens... I don't have it set to free the pic, and when i do, it does the same thing. I've tried re-writing my code about 4 different ways and it still doesnt want to work. Any help? please
Display posts from previous:   
   Index -> Programming, Turing -> Turing Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 25 Posts ]
Goto page 1, 2  Next
Jump to: