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

Username:   Password: 
 RegisterRegister   
 Sprite to pic converter
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
mirhagk




PostPosted: Wed Dec 09, 2009 8:28 am   Post subject: Sprite to pic converter

Remember all those awesome sprites in RPG maker that we all used and are all over the web, wouldn't it be awesome to use those in your game?? well this program takes a sprite file and converts it into picture files for you. Put the picture into a folder called "raw" in the same folder, and create another folder with the main program called "done". It will take a pic out of raw and put it finished into a folder called its picture name within done.
it works pretty well, could be improved a bit but it's very useful nonetheless

Turing:

var win := Window.Open ("graphics:500;500,nobuttonbar")
var pic : int
var picname : string
var width : int
var height : int
var picsample : int
var name : string
var dir := "left"
var num := 1

put "Please enter the name of the picture you would like split:"
get picname
pic := Pic.FileNew ("raw/" + picname)
width := ((Pic.Width (pic) div 12) * 3)
height := ((Pic.Height (pic) div 8) * 3) - 1
pic := Pic.Scale (pic, Pic.Width (pic) * 3, Pic.Height (pic) * 3)
cls
Pic.Draw (pic, 0, 0, picMerge)
put "Press any key to start cutting out pieces:" ..
Input.Pause
for Y : 1 .. 2
    for X : 1 .. 4
        Pic.Draw (pic, (-width * 3 * (X - 1)), (-height * 4 * (Y - 1)) + 1, picMerge)
        Pic.ScreenSave (0, 0, width, height, "temp.bmp")
        cls
        picsample := Pic.FileNew ("temp.bmp")
        Pic.Draw (picsample, 0, 0, picMerge)
        put "What is this character called?:"
        get name
        Dir.Create ("done/" + name)
        Pic.Save (picsample, "done/" + name + "/" + name + dir + intstr (num) + ".bmp")
        for y : 1 .. 4
            if y = 1 then
                dir := 'left'
            elsif y = 2 then
                dir := 'down'
            elsif y = 3 then
                dir := 'right'
            else
                dir := 'up'
            end if
            for x : 1 .. 3
                put "Piece complete press any key to continue:" ..
                Input.Pause
                Pic.Draw (pic, -width * 3 * (X - 1) - width * (x - 1), -height * 4 * (Y - 1) - height * (y - 1), picMerge)
                Pic.ScreenSave (0, 0, width, height, "done/" + name + "/" + name + dir + intstr (x) + ".bmp")
                cls
                picsample := Pic.FileNew ("done/" + name + "/" + name + dir + intstr (x) + ".bmp")
                Pic.Draw (picsample, 0, 0, picMerge)
            end for
        end for
    end for
end for
cls
put "Everything is finished," ..
delay (200)
put " press any key to quit:" ..
Window.Close (win)
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: