Sprite freed when there's no free sprite
Author |
Message |
Logic
|
Posted: Wed May 31, 2017 1:42 pm Post subject: Sprite freed when there's no free sprite |
|
|
What is it you are trying to achieve?
What is the problem you are having?
Hi, im doing my final project and its to make a game ive recently hit a stump when i run my game and I click the play option it says my sprite was freed but i don't have sprite.free
Describe what you have tried to solve this problem
ive tried using the include option but its doesnt even show the sprite when its running
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Answer Here
Turing: |
%Jeffrey
%May 17th
%Finalproject.t
%to make a driving game
%Variables
var pic3 : int
var pic2 : int
var font, x, y, notused1, notused2 : int
var sprite1 : int
var sprite2 : int
var flag : int := 0
font := Font.New ("Arial:40:Bold")
var font1 := Font.New ("Arial:12:Bold")
var font3 := Font.New ("Arial:75: Bold")
var pic1 : int
var music1 : boolean
var chars : array char of boolean
var xShip, yShip : int
var sprite3 : int
pic3 := Pic.FileNew ("ship90.jpg")
pic3 := Pic.Scale (pic3, 75, 75)
sprite3 := Sprite.New (pic3 )
Sprite.Show (sprite3 )
xShip := 100
yShip := 100
%Screen size and Background
setscreen ("graphics:900;600")
drawfillbox (0, 0, maxx, maxy, 248)
pic2 := Pic.FileNew ("Untitled-2.jpg")
pic2 := Pic.Scale (pic2, 150, 150)
%menu
Font.Draw ("S P A C E R A C E R L A S S E R", 40, 500, font, white)
drawfillbox (100, 300, 450, 350, 9)
drawfillbox (100, 200, 450, 250, 9)
drawfillbox (100, 100, 450, 150, 9)
Font.Draw ("Play", 220, 310, font, black)
Font.Draw ("Instructions", 130, 210, font, black)
Font.Draw ("Credits", 200, 110, font, black)
buttonwait ("down", x, y, notused1, notused2 )
%What happens when the button is clicked
if x > 100 and x < 450 and y > 300 and y < 350 then
cls
drawfillbox (0, 0, maxx, maxy, 248)
Font.Draw ("Loading", 250, 300, font3, white)
delay (1500)
cls
drawbox (5, 5, maxx - 5, maxy - 5, white)
loop
Sprite.SetPosition (sprite3, xShip, yShip, true)
Input.KeyDown (chars )
if chars (KEY_UP_ARROW) then
yShip := yShip + 5
end if
if chars (KEY_RIGHT_ARROW) then
xShip := xShip + 5
end if
if chars (KEY_LEFT_ARROW) then
xShip := xShip - 5
end if
if chars (KEY_DOWN_ARROW) then
yShip := yShip - 5
end if
Sprite.Show (sprite3 )
delay (10)
if yShip >= maxy - 33 then
yShip := maxy - 33
end if
end loop
elsif x > 100 and x < 450 and y > 200 and y < 250 then
cls
drawfillbox (0, 0, maxx, maxy, 248)
Font.Draw ("How To Play", 320, 500, font, white)
Font.Draw ("You are a space engineer for Lasser Corp,", 440, 450, font1, white)
Font.Draw ("You just finished work realising that the", 440, 430, font1, white)
Font.Draw ("mothership has left you. You will embark on", 440, 410, font1, white)
Font.Draw ("a journey through the space gravyard and asteroid field", 440, 390, font1, white)
Font.Draw ("Your goal is to make it home alive.", 440, 370, font1, white)
Font.Draw ("Get points by avoiding space junk and asteroids", 440, 350, font1, white)
pic1 := Pic.FileNew ("Untitled-1.jpg")
pic1 := Pic.Scale (pic1, 200, 200)
Pic.Draw (pic1, 75, 50, picMerge)
Font.Draw ("Up", 165, 250, font1, white)
Font.Draw ("Down ", 155, 40, font1, white)
Font.Draw ("Left", 40, 100, font1, white)
Font.Draw ("Right", 280, 100, font1, white)
drawfillbox (700, 0, 900, 50, 9)
drawfillbox (400, 0, 600, 50, 9)
Font.Draw ("Menu", 440, 10, font, white)
Font.Draw ("Play", 750, 10, font, white)
elsif x > 100 and x < 450 and y > 100 and y < 150 then
cls
drawfillbox (0, 0, maxx, maxy, 248)
end if
|
Please specify what version of Turing you are using
1.0.1 |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Insectoid
|
Posted: Wed May 31, 2017 2:30 pm Post subject: RE:Sprite freed when there\'s no free sprite |
|
|
You're in luck, I just discovered this bug in Turing a week ago!
When you change the size of the run window with View.Set or setscreen, all previously created sprites are freed. There is no documentation that I'm aware of which explains this behavior. It is an issue with Turing itself.
The solution is to move your setscreen call to the very top of the program. If it's the very first line, you should never run into this problem. |
|
|
|
|
|
ProxyKaliber
|
Posted: Fri Jun 02, 2017 8:33 am Post subject: Re: Sprite freed when there's no free sprite |
|
|
Interesting, I'm using 4.1.1 and this problem occurs in 1.0.1 so do you think that I would encounter this issue? Should I test it to see if it happens for my version of turing? |
|
|
|
|
|
|
|