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

Username:   Password: 
 RegisterRegister   
 Sprite.Show doesn't work with include
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Alboxas




PostPosted: Tue Jan 19, 2016 11:33 am   Post subject: Sprite.Show doesn't work with include

What is it you are trying to achieve?
Use Sprite.Show with include.


What is the problem you are having?
Sprite.Show does not allow sprites to load in the included file.


Describe what you have tried to solve this problem

Everything

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)


Turing:

%File1

include "Classes/var.t"
down1 := Pic.FileNew ("0.bmp")
up1 := Pic.FileNew ("0.bmp")
left1 := Pic.FileNew ("0.bmp")
right1 := Pic.FileNew ("0.bmp")
character := Sprite.New (up1)
Sprite.SetPosition (character, characterx * 20 + 10, charactery * 20 + 10 + 7, true)
Sprite.Show (character)
include "Classes/KnightFight.t"
%--------------------------------------------------------------------------------------------------
%KnightFight.t

setscreen ("graphics: 640, 540")
EnemyFlag := 0
Pic.ScreenLoad ("Sprites/BGBMP/5.bmp", 0, 185, picCopy)
%Pic.ScreenLoad ("Sprites/hud copy.bmp", 0, 0, picMerge)
Pic.ScreenLoad ("Classes/buttons/hud.bmp", 0, 0, picMerge)

Pic.ScreenLoad ("Classes/buttons/sword.bmp", 350, 30, picMerge) %80x80
Pic.ScreenLoad ("Classes/buttons/hp.bmp", 440, 30, picMerge)
Pic.ScreenLoad ("Classes/buttons/hp.bmp", 530, 30, picMerge)

pic1 := Pic.FileNew ("Sprites/Ephriam/Critical BMP/crit1.bmp")
width := Pic.Width (pic1)
height := Pic.Height (pic1)
pic1 := Pic.Scale (pic1, width * 3, height * 3)
sprite1 := Sprite.New (pic1)
Sprite.SetPosition (sprite1, 400, 241, false)
Sprite.Show (sprite1)

pic184 := Pic.FileNew ("Sprites/Knight/Basic BMP/19.bmp")
width := Pic.Width (pic184)
height := Pic.Height (pic184)
pic184 := Pic.Scale (pic184, width * 4, height * 4)
sprite2 := Sprite.New (pic184)
Sprite.SetPosition (sprite2, 70, 241, false)
Sprite.Show (sprite2)

for i : 1 .. 19 by 1
    knibas (i) := Pic.FileNew ("Sprites/Knight/Basic BMP/" + intstr (i) + ".bmp")
    width := Pic.Width (knibas (i))
    height := Pic.Height (knibas (i))
    knibas (i) := Pic.Scale (knibas (i), width * 4, height * 4)
end for

%Heal
for i : 0 .. 13
    healpic (i) := Pic.FileNew ("Sprites/heal/" + intstr (i) + ".bmp")
end for

for i : 0 .. 13
    healsprite (i) := Sprite.New (healpic (i))
end for

%Temp Vars
var hp1 : int := 305
var crit2, crit1 : int
var turn : int := 0

%Critical
for i : 1 .. 31 by 1
    View.Update
    crit (i) := Pic.FileNew ("Sprites/Ephriam/Critical BMP/crit" + intstr (i) + ".bmp")
    width := Pic.Width (crit (i))
    height := Pic.Height (crit (i))
    crit (i) := Pic.Scale (crit (i), width * 3, height * 3)
end for

for i : 0 .. 8 by 1
    View.Update
    blood1 (i) := Pic.FileNew ("Sprites/blood2/" + intstr (i) + ".bmp")
    blood1 (i) := Pic.Flip (blood1 (i))
    width := Pic.Width (blood1 (i))
    height := Pic.Height (blood1 (i))
    blood1 (i) := Pic.Scale (blood1 (i), width * 3, height * 3)
end for

for i : 1 .. 8 by 1
    View.Update
    crithit (i) := Pic.FileNew ("Sprites/Hit effects/Critical/" + intstr (i) + ".bmp")
end for

pic1 := Pic.FileNew ("Sprites/Ephriam/Critical BMP/crit1.bmp")
width := Pic.Width (pic1)
height := Pic.Height (pic1)
pic1 := Pic.Scale (pic1, width * 2, height * 2)

Sprite.SetPosition (sprite1, 400, 241, false)
Sprite.Show (sprite1)

critpic := Pic.FileNew ("Sprites/Hit effects/Critical/1.bmp")
critfx := Sprite.New (critpic)

%Blood
blood1pic := Pic.FileNew ("Sprites/blood2/0.bmp")
critblood := Sprite.New (blood1pic)

Sprite.SetPosition (critfx, 0, 80, false)
Sprite.SetPosition (critblood, 100, 280, false)

%Basic
for i : 0 .. 21 by 1
    bas (i) := Pic.FileNew ("Sprites/Ephriam/Basic BMP/bas" + intstr (i) + ".bmp")
    width := Pic.Width (bas (i))
    height := Pic.Height (bas (i))
    bas (i) := Pic.Scale (bas (i), width * 3, height * 3)
end for

for i : 0 .. 8 by 1
    hit (i) := Pic.FileNew ("Sprites/Hit effects/Basic/" + intstr (i) + ".bmp")
    blood2 (i) := Pic.FileNew ("Sprites/blood1/" + intstr (i) + ".bmp")
end for

pic1 := Pic.FileNew ("Sprites/Ephriam/Basic BMP/bas0.bmp")
width := Pic.Width (pic1)
height := Pic.Height (pic1)
pic1 := Pic.Scale (pic1, width * 3, height * 3)

Sprite.SetPosition (sprite1, 400, 241, false)
Sprite.Show (sprite1)

baspic := Pic.FileNew ("Sprites/Hit effects/Basic/0.bmp")
basfx := Sprite.New (baspic)

%Blood
blood1pic := Pic.FileNew ("Sprites/blood1/0.bmp")
basblood := Sprite.New (blood1pic)

Sprite.SetPosition (basfx, 0, 90, false)
Sprite.SetPosition (basblood, 190, 280, false)

%Hp
drawfillbox (335, 162, hp, 172, 40)
drawfillbox (15, 162, hp1, 172, 40)


%MouseWhere
loop
    mousewhere (x, y, button)
    if hp < 336 then
        EnemyFlag := 2
        exit
    end if
    %Enemy HP Modifiers
    if HudClick (x, y, 350, 30, 430, 110) and turn = 0 then

        randint (crit2, 1, 5)

        if crit2 = 1 then
            include "Ephriam/Critical.t"

            hp1 -= weapon * 4
            drawfillbox (15, 162, 305, 172, white)
            drawfillbox (15, 162, hp1, 172, 40)
            if hp1 < 16 then
                EnemyFlag := 1
                exit
            end if
            delay (200)
            delay (1300)
            include "Knight/Basic.t"
            hp -= 60 - armor
            drawfillbox (335, 162, 625, 172, white)
            drawfillbox (335, 162, hp, 172, 40)
            turn := 0
        else
            include "Ephriam/Basic.t"

            hp1 -= weapon
            drawfillbox (15, 162, 305, 172, white)
            drawfillbox (15, 162, hp1, 172, 40)
            if hp1 < 16 then
                EnemyFlag := 1
                exit
            end if
            delay (200)
            delay (1300)
            include "Knight/Basic.t"
            hp -= 60 - armor
            drawfillbox (335, 162, 625, 172, white)
            drawfillbox (335, 162, hp, 172, 40)
            turn := 0
        end if
    end if
    if hp1 < 16 then
        exit
    end if

    if hp < 336 then
        exit
    end if
    if HudClick (x, y, 440, 30, 520, 110) and turn = 0 and hp < 610 then
        healX := 420
        for i : 0 .. 13
            Sprite.SetPosition (healsprite (i), healX, 230, false)
            Sprite.Show (healsprite (i))
            delay (60)
            Sprite.Hide (healsprite (i))
        end for

        hp += 150
        drawfillbox (335, 162, 625, 172, white)
        drawfillbox (335, 162, hp, 172, 40)
        delay (10)
        delay (1300)
        include "Knight/Basic.t"
        hp -= 60 - armor
        drawfillbox (335, 162, 625, 172, white)
        drawfillbox (335, 162, hp, 172, 40)
        turn := 0

    end if
end loop
if EnemyFlag = 1 then %Emp wins
    Sprite.Free (sprite2)
    Pic.ScreenLoad ("Classes/buttons/hud.bmp", 0, 0, picMerge)
    View.Update
elsif EnemyFlag = 2 then %Enemy wins
    Sprite.Free (sprite1)
    Pic.ScreenLoad ("Classes/buttons/hud.bmp", 0, 0, picMerge)
    View.Update
end if



Please specify what version of Turing you are using
4.1.1
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Tue Jan 19, 2016 3:05 pm   Post subject: RE:Sprite.Show doesn\'t work with include

Telling us you tried everything doesn't tell us anything. If you've tried everything and nothing has worked then it can't be done. You don't know what everything is, so I really doubt you've tried that. I don't even know what everything is. If you tell us specifically what you've tried though, then we don't waste time suggesting things you've already done.

Did Turing give you any specific error messages or did the sprites just not appear on the screen?
Alboxas




PostPosted: Tue Jan 19, 2016 6:50 pm   Post subject: RE:Sprite.Show doesn\'t work with include

There are no error messages, the second file runs but the sprites do not load and is unable to be called. I have tried changing the pictures, freeing the character sprite that is declared before the include. I have tried hiding the sprite. The only thing that will allow the included file to properly run is to remove Sprite.Show completely from the first file. I have also tried including another .t file that will do the sprite.show for me from a different directory but it still doesn't work. For some reason, the Sprite.Show conflicts with the code in the KnightFight.t file.
Insectoid




PostPosted: Tue Jan 19, 2016 7:45 pm   Post subject: RE:Sprite.Show doesn\'t work with include

Does it work if you manually copy & paste all the files into one big file?
Alboxas




PostPosted: Wed Jan 20, 2016 9:11 am   Post subject: RE:Sprite.Show doesn\'t work with include

No it doesn't
Alboxas




PostPosted: Wed Jan 20, 2016 9:13 am   Post subject: RE:Sprite.Show doesn\'t work with include

alright i found it, setscreen makes the second program unusable, removing will allow the sprites to load.
Alboxas




PostPosted: Wed Jan 20, 2016 9:22 am   Post subject: RE:Sprite.Show doesn\'t work with include

basically, the sprites wont load if the resolution is changed. Weird, but after making the resolutions for both the files the same, the sprites loaded.
Insectoid




PostPosted: Wed Jan 20, 2016 1:03 pm   Post subject: RE:Sprite.Show doesn\'t work with include

Did you by chance use 'offscreenonly' in your call to setscreen? Sprites kinda do things their own way and don't play nicely with offscreenonly. I think that's far more likely to be the issue than changing the resolution.
Sponsor
Sponsor
Sponsor
sponsor
Alboxas




PostPosted: Fri Jan 22, 2016 10:08 am   Post subject: RE:Sprite.Show doesn\'t work with include

nope, no offscreenonly, i checked for that a long time ago
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 1  [ 9 Posts ]
Jump to:   


Style:  
Search: