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

Username:   Password: 
 RegisterRegister   
 Need help with sprites
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Pyroguy




PostPosted: Fri Mar 21, 2003 11:51 pm   Post subject: Need help with sprites

Hey, I was wondering if one of you guys could give me a simple program that animates a sprite, because I'm making a mortal combat style game, but I only have a vague idea of how to make sprites... I know how to create pictures using bmps from a file, and i know that you have to declare an array of pictures to use in the sprite, but I'm not quite so sure about the code to declare the arrays, and also the Sprite.Animate command or any of the other sprite commands for that matter... plz help me Question Question Question Very Happy

Thx
Sponsor
Sponsor
Sponsor
sponsor
Pyroguy




PostPosted: Sat Mar 22, 2003 12:03 am   Post subject: One more thing...

How do I change the size of the turing run window?
i.e. make it fullscreen instead of just the one corner... I'm on object oriented turing 4.0.1 [k]
Tony




PostPosted: Sat Mar 22, 2003 12:09 am   Post subject: (No subject)

you cant have sprites in v4.x, only 3.1... well atleast not yet. You can have images with transparent background if you want. Use PicMerge mode.

as for resizing your window

code:

View.Set("graphics:800;600")
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Delta




PostPosted: Sat Mar 22, 2003 12:16 am   Post subject: (No subject)

To make the run window fullscreen just type in setscreen ("fullscreen")
Blade




PostPosted: Sat Mar 22, 2003 12:22 am   Post subject: (No subject)

you can also use
code:

View.Set("Graphics:maxx;maxy")
Pyroguy




PostPosted: Sat Mar 22, 2003 12:26 am   Post subject: school has different version

I think the turing version at my school is the newest version, and I know for a fact that you can make sprites on it. Hypothetically, what would the source code be if I wanted to make a sprite with three frames?
Tony




PostPosted: Sat Mar 22, 2003 12:44 am   Post subject: (No subject)

newest version is 4.x is I dont think they have sprites yet. (4 is the one with color coded editor)

if you got v3.1 then
code:

var pics : array 0 .. 5 of int
        var sprite: int
        for i : 1 .. 6
            pics (i  1) := Pic.FileNew ("Pic" + intstr (i) + ".bmp")
            if Error.Last not= 0 then
                put "Error loading image: ", Error.LastMsg
                return
            end if
        end for
        sprite:= Sprite.New (pics (0))
        Sprite.SetPosition (sprite, 0, 100, false)
        Sprite.Show (sprite)
        for x : 2 .. maxx by 2
            Sprite.Animate (sprite, pics ((x div 2) mod 6), x, 100, false)
        end for
        Sprite.Free (sprite)


atleast thats an example from turing's help file.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Delta




PostPosted: Sat Mar 22, 2003 12:57 am   Post subject: (No subject)

Your right Turing 4 doesn't support Sprites...yet I'll ask Tom West when they will be done it. (Tom West is the lead programmer for Turing)
Sponsor
Sponsor
Sponsor
sponsor
Pyroguy




PostPosted: Sat Mar 22, 2003 11:41 pm   Post subject: yeah that's what i was looking for

Thx for that code... that code was what i looked at from my schools help file and i can't access that help file from home. Anyway... you guys have a great site running here and im sure ill be back if i need help Laughing
Pyroguy




PostPosted: Sun Mar 23, 2003 12:20 am   Post subject: Calling a sprite as a procedure

I should probably post all my questions in one message, but I keep forgetting things I want to ask and new things keep coming to me... anyway... here is my question...

Is there any way that I could designate the creation of a sprite to a procedure, but change some of the parameters of the sprite...
ex:

var dubya : array 1 .. 3 of int
var dubselected : int
for i : 1 .. 3
dubya (i) := Pic.FileNew ("dubyaselected" + intstr (i) + ".bmp")
if Error.Last not= 0 then
put "Try again dumbass", Error.LastMsg
return
end if
end for
procedure spritecreate()
dubselected := Sprite.New (dubya (0))
Sprite.SetPosition (dubselected, 0, 100, false)
Sprite.Show (dubselected)
for x : 2 .. maxx by 2
Sprite.Animate (sprite, pics ((x div 2) mod 6), x, 100, false)
end for
Sprite.Free (dubselected)
spritecreate()

Say for example, that I wanted to create another sprite with the same commands, but different names for the variables... instead of the sprite being called dubselected, it could be osamaselected, or instead of the sprite being displayed on 0, 100 it could be changed to 100, 200. This is an example of the code I'm going to use for my mortal politician game.

If I haven't made what I'm trying to do clear, let me try it again...
I want to change parameters of the procedure, so that I can call upon it using different names and numbers, and not have to write the code completely over again. This must be very confusing... sorry I can't be clearer.
Asok




PostPosted: Sun Mar 23, 2003 2:53 am   Post subject: (No subject)

easiest way to do that is with an array and have the different names in the array.
Tony




PostPosted: Sun Mar 23, 2003 2:30 pm   Post subject: (No subject)

you can read a tutorial on procedures with arguments on examples and explanation of how you can pass values into a procedure.

Just to let you know, you cant have a user specified variable name... and you dont need to, since user never sees variable names anyway. What you do is you create an array and fill it with values. Though if you want to assign names, you can also have another array storing names assosiated with cells in another array.

let me explain:
arrayName(1):= "tony"
arrayName(2):= "dan"

arrayBits(1):= 10000 Wink
arrayBits(2):= 1000

from there you can just use number to access array points in arrayBits. But if you want to find how many bits TONY has, you search through first array to find which cell contains tony, then use that number to access arrayBits(1).

It can also be done if array is decleared as a 2D one.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Asok




PostPosted: Sun Mar 23, 2003 3:27 pm   Post subject: (No subject)

arrayName(3):= "Asok"

arrayBits(3) := arrayBits(1) + arrayBits(2)

oooo I am the KING OF BITS! BOW BEFORE ME! MWAHAHAHAHA Twisted Evil
Tony




PostPosted: Sun Mar 23, 2003 3:46 pm   Post subject: (No subject)

not unless arrayBits(1) and arrayBits(2) are both negative Twisted Evil
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Asok




PostPosted: Sun Mar 23, 2003 5:52 pm   Post subject: (No subject)

but you had allready set the values of arrayBits(1) and arrayBits(2) Rolling Eyes

Just call me the Bit King and you shall be forgiven.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

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


Style:  
Search: