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

Username:   Password: 
 RegisterRegister   
 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
maiku




PostPosted: Mon Mar 13, 2006 10:22 pm   Post subject: Sprites

!!!

I can't figure what a sprite is, let alone how to use it.....I'm a total noob

I believe a sprite is an image that I use in my program, like the main character, and if I'm wrong, please correct me!

If I'm right, then someone please tell me what command I use to do this, because the turing help guide isn't exactly very specific...I need an example, or a fake example...
Please???
Sponsor
Sponsor
Sponsor
sponsor
Dan




PostPosted: Tue Mar 14, 2006 1:53 am   Post subject: (No subject)

Sprites only work in versons of turing less then 4.0.1 or greater then 4.0.4c. And even in 4.0.5 they are ify.

What they are is an image witch can be moved with out destoying the backgorund image. However this is not the best way to do this and in the new versons of turing you should be using View.Update and offscreen graphicsks mode to do animation.

For more information on both subjects please use the search function or look threw the tutorals. Or you could post your questions here, i guses =p.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Imm0rtal




PostPosted: Tue Mar 14, 2006 2:00 am   Post subject: (No subject)

Sprites are usually the graphics used for different "people" IE: the characters you control/interact with.. Often times you get a sprite "sheet" which has different positions for each possible move the user would make..

EXAMPLE:
http://www.northcastle.co.uk/archive/vault/sprites/link2.gif

In Turing the sprite functions give you control over linking these images and then depending on a getch statement you can move them around..

I personally do not use the sprite functions.. Thats not how I started my current project and I had no intention of switching over.

Test:

THE BELOW CODE IS SLOPPY:
One reason is your not releasing pictures your done with.. so after 1000 steps your program will crash. Also there are a number other reasons why this is sloppy but for the sake of easy to follow code I like it. You will need 12 pictures total.

3 Different pictures for him walking UP, DOWN, LEFT, RIGHT (Think Zelda)
Each picture should be named as such:
UP1.bmp
UP2.bmp
UP3.bmp
DOWN1.bmp
ect...

Goodluck


code:

View.Set ("offscreenonly")
setscreen ("graphics:vga")
setscreen ("nocursor")
var keypress : string (1)
var spriteID := Pic.FileNew ("RIGHT1.bmp")
var corX, corY : int := 220
var StepCount : int := 1

Pic.Draw (spriteID, 220, 220, picMerge)


loop
        getch (keypress)  % MAIN ACTION GETCH COMMAND
       



        if (keypress) = (KEY_UP_ARROW) then
            corY := corY + 5
            if StepCount = 1 then
                Pic.Free (spriteID)
                spriteID := Pic.FileNew ("UP1.bmp")
                StepCount := StepCount + 1
            elsif StepCount = 2 then
                Pic.Free (spriteID)
                spriteID := Pic.FileNew ("UP2.bmp")
                StepCount := StepCount + 1
            else
                Pic.Free (spriteID)
                spriteID := Pic.FileNew ("UP3.bmp")
                StepCount := 1
            end if

        elsif (keypress) = (KEY_RIGHT_ARROW) then         %Key Right Arrow
            corX := corX + 5
            if StepCount = 1 then
                Pic.Free (spriteID)
                spriteID := Pic.FileNew ("RIGHT1.bmp")
                StepCount := StepCount + 1
            elsif StepCount = 2 then
                Pic.Free (spriteID)
                spriteID := Pic.FileNew ("RIGHT2.bmp")
                StepCount := StepCount + 1
            else
                Pic.Free (spriteID)
                spriteID := Pic.FileNew ("RIGHT3.bmp")
                StepCount := 1
            end if

        elsif (keypress) = (KEY_LEFT_ARROW) then         %Key Left Arrow
            corX := corX - 5
            if StepCount = 1 then
                Pic.Free (spriteID)
                spriteID := Pic.FileNew ("LEFT1.bmp")
                StepCount := StepCount + 1
            elsif StepCount = 2 then
                Pic.Free (spriteID)
                spriteID := Pic.FileNew ("LEFT2.bmp")
                StepCount := StepCount + 1
            else
                Pic.Free (spriteID)
                spriteID := Pic.FileNew ("LEFT3.bmp")
                StepCount := 1
            end if

        elsif (keypress) = (KEY_DOWN_ARROW) then         %Key Down Arrow
            corY := corY - 5
            if StepCount = 1 then
                Pic.Free (spriteID)
                spriteID := Pic.FileNew ("DOWN1.bmp")
                StepCount := StepCount + 1
            elsif StepCount = 2 then
                Pic.Free (spriteID)
                spriteID := Pic.FileNew ("DOWN2.bmp")
                StepCount := StepCount + 1
            else
                Pic.Free (spriteID)
                spriteID := Pic.FileNew ("DOWN3.bmp")
                StepCount := 1
            end if

        end if


       
        %DEBUG:::
        color (3)
        colorback (255)
        cls
        Pic.Draw (spriteID, corX, corY, picMerge) % DRAW SPRITE
        View.Update
end loop
Twisted Evil
maiku




PostPosted: Tue Mar 14, 2006 12:29 pm   Post subject: Thanks....???

Thanks for the info guys

If you think I'm kinda dumb, you'd be guessing right....

I use Turing 4.0.5 so sprites hould work, but I'm still a little confused

Any more info would help but I think I got it

THANKS! Very Happy
[Gandalf]




PostPosted: Tue Mar 14, 2006 6:54 pm   Post subject: (No subject)

Sprites in Turing 4.0.5 are only either using the Pic module, or else using a third party library, like DanSprite or BacchusSprite. You do not have the ability to use the Sprite module, but sprite graphics manipulation is quite possible using the Pic module, as long as you redraw the background at every frame.
maiku




PostPosted: Thu Mar 23, 2006 4:01 pm   Post subject: Sprites

Confused ok.....

This kinda helped......It took me this long to figure it all out, and I noticed that I'm not getting any good information, everyone si just complaining that I shouldn't use sprites......But honestly, It's the way I want to do it.....So ANYONE PLEASE TELL ME HOW!!!!!

I think I'm doing it right, but i got mad and deleted my code.....the problem was that my sprites weren't appearing

Help anyone???
Imm0rtal




PostPosted: Thu Mar 23, 2006 6:41 pm   Post subject: (No subject)

I would have to see your source code to tell you what was wrong with it.. OH YEA! you deleted it.. smooooth.

My source code would work find and it is reccomended you use it. You asked for our help and we gave it to you. If it is too complicated to copy and paste my source code into turing.. Get 9 pictures with the proper names. Then perhaps your in the wrong forum.

Sorry but we can't make it any simpler.. Confused
Imm0rtal




PostPosted: Thu Mar 23, 2006 6:42 pm   Post subject: (No subject)

Make that 12 pictures
Sponsor
Sponsor
Sponsor
sponsor
rizzix




PostPosted: Thu Mar 23, 2006 7:58 pm   Post subject: (No subject)

Imm0rtal easy on the double post.
maiku




PostPosted: Fri Mar 24, 2006 3:33 pm   Post subject: (No subject)

I am thankful for your help, and no, its not too complicated to copy your code into turing, but i have almost the exact same program, but a bit smoother

And that last post really made no sense what so ever........

But thats anyways
maiku




PostPosted: Fri Mar 24, 2006 3:35 pm   Post subject: (No subject)

Here's my coding program, zipped


woot!.zip
 Description:

Download
 Filename:  woot!.zip
 Filesize:  123.04 KB
 Downloaded:  76 Time(s)

Imm0rtal




PostPosted: Fri Mar 24, 2006 6:10 pm   Post subject: (No subject)

I got an error when running the program. Laughing
[Gandalf]




PostPosted: Sat Mar 25, 2006 12:34 am   Post subject: (No subject)

I don't. And I don't see the problem, the code works fine on both Turing 4.0.5 and Turing 4.1. There are many ways I would suggest improving the code (ie. split it up into procedures/functions, only use one delay in the loop, etc) but it seems to work for your purposes. You must ask a question first before getting an answer.
maiku




PostPosted: Sun Mar 26, 2006 8:21 am   Post subject: (No subject)

The program does work, just make sure you have the folder 'chrono' in the same location as the .t file

I was wondering if someone could change my coding, or redo my coding, so that It is done with the Sprite module, and not Pic

Oh, and there needs to be a lot of delays, just because of the way the images are set up. The character (chrono) takes a step, but he always returns to a standing still position facing the way that he just moved
Imm0rtal




PostPosted: Sun Mar 26, 2006 11:29 am   Post subject: (No subject)

You should get rid of the delays... they make a slight pause everytime you press a key that is very annoying..

also if you want him to face the same way after you move him.. that shouldn't be very difficult at all. Smile
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: