Relatively New : Pic.Width Incompatability (Invalid Pic ID) with Sprites
Author |
Message |
Virtuosity of Inaction
|
Posted: Sun Oct 13, 2013 10:34 pm Post subject: Relatively New : Pic.Width Incompatability (Invalid Pic ID) with Sprites |
|
|
What is it you are trying to achieve?
I am trying to program (admittedly miserably, with flogging hopes) an actuator or mechanism to perform the action of spatially manipulating a doublet of separate objects along the x-axis, abiding by the policy of a stipulated condition defined by the "if" operator and operands, in the context of Sprite animations. The stipulation is qualitatively straight-forward or conceptually simple in the framework of my objective : objects are moved by the user and when the objects coincide or collide, the images change and an appropriate message is displayed to the user.
What is the problem you are having?
As indicated or suggested in the title, I am experiencing difficulties with configuring the stipulations to define a coincidence event in the interaction of the user with the spatial objects. In the below code, you will see "if" conditionals (e.g. if xPositionTank < 600 then and not xPositionTank + Pic.Width (TankWalkR) > xPositionBomb then"). However, when I run the program, the program returns the error notification, "Invalid Pic ID", causing my program to misbehave or malfunction.
Describe what you have tried to solve this problem
I have tried redefining the Pic parameters in the Twalk and Bwalk features, but have not integrated and synthesized results.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing: |
View.Set ("graphics:600,400, nobuttonbar, nocursor")
% Landscape Parameters with drawfill operators
% Blue Sky Background
drawfillbox (0, 0, maxx, maxy, 52)
% Grassy Platform
drawfillbox (0, 0, maxx, 50, green)
% Sun and two companion clouds
drawfilloval (100, 340, 40, 40, red)
drawfilloval (500, 330, 30, 30, grey)
drawfilloval (500, 310, 30, 30, grey)
drawfilloval (480, 330, 30, 30, grey)
drawfilloval (480, 310, 30, 30, grey)
drawfilloval (460, 320, 30, 30, grey)
drawfilloval (520, 320, 30, 30, grey)
drawfilloval (200, 330, 30, 30, grey)
drawfilloval (200, 310, 30, 30, grey)
drawfilloval (180, 330, 30, 30, grey)
drawfilloval (180, 310, 30, 30, grey)
drawfilloval (160, 320, 30, 30, grey)
drawfilloval (220, 320, 30, 30, grey)
var numFrames : int := 2
var TwalkRight : array 0 .. numFrames of int
var TwalkLeft : array 0 .. numFrames of int
var BwalkRight : array 0 .. numFrames of int
var BwalkLeft : array 0 .. numFrames of int
var chars : array char of boolean
var xPositionTank := 0
var yPositionTank := 100
var xPositionBomb := maxx
var yPositionBomb := 100
for picNo : 0 .. numFrames
TwalkRight (picNo ) := Pic.FileNew ("TankR" + intstr (picNo ) + ".jpg")
end for
for picNo : 0 .. numFrames
TwalkLeft (picNo ) := Pic.FileNew ("TankL" + intstr (picNo ) + ".jpg")
end for
for picNo : 0 .. numFrames
BwalkRight (picNo ) := Pic.FileNew ("Bomb" + intstr (picNo ) + ".jpg")
end for
for picNo : 0 .. numFrames
BwalkLeft (picNo ) := Pic.FileNew ("Bomb" + intstr (picNo ) + ".jpg")
end for
var TankWalkR := Sprite.New (TwalkRight (1))
Sprite.SetPosition (TankWalkR, xPositionTank, yPositionTank, false)
var TankWalkL := Sprite.New (TwalkLeft (1))
var BombWalkR := Sprite.New (BwalkRight (1))
Sprite.SetPosition (BombWalkR, xPositionBomb, yPositionBomb, false)
var BombWalkL := Sprite.New (BwalkLeft (1))
Sprite.Show (TankWalkR )
loop
Input.KeyDown (chars )
if chars (KEY_RIGHT_ARROW) then
if xPositionTank < 600 then and not xPositionTank + Pic.Width (TankWalkR ) > xPositionBomb then
Sprite.Hide (TankWalkL )
xPositionTank + = 8
Sprite.Show (TankWalkR )
Sprite.Animate (TankWalkR, TwalkRight ((xPositionTank div 3) mod numFrames ), xPositionTank, yPositionTank, false)
delay (40)
end if
Sprite.Animate (TankWalkR, TwalkRight (1), xPositionTank, yPositionTank, false)
elsif chars (KEY_LEFT_ARROW) then
if xPositionTank > 0 and not xPositionTank + Pic.Width (TankWalkR ) > xPositionBomb then
Sprite.Hide (TankWalkR )
xPositionTank + = 8
Sprite.Show (TankWalkL )
Sprite.Animate (TankWalkL, TwalkLeft ((xPositionTank div 3) mod numFrames ), xPositionTank, yPositionTank, false)
delay (40)
end if
Sprite.Animate (TankWalkR, TwalkRight (1), xPositionTank, yPositionTank, false)
elsif chars (KEY_UP_ARROW) then
if xPositionBomb < 600 and not xPositionBomb + Pic.Width (BombWalkR ) > xPositionTank then
Sprite.Hide (BombWalkR )
xPositionBomb - = 8
Sprite.Show (BombWalkL )
Sprite.Animate (BombWalkL, BwalkLeft ((xPositionBomb div 3) mod numFrames ), xPositionBomb, yPositionBomb, false)
delay (40)
end if
Sprite.Animate (BombWalkR, BwalkRight (1), xPositionBomb, yPositionBomb, false)
elsif chars (KEY_DOWN_ARROW) then
if xPositionBomb > 0 and not xPositionBomb + Pic.Width (BombWalkR ) > xPositionTank then
Sprite.Hide (BombWalkL )
xPositionBomb - = 8
Sprite.Show (BombWalkR )
Sprite.Animate (BombWalkR, BwalkRight ((xPositionBomb div 3) mod numFrames ), xPositionBomb, yPositionBomb, false)
delay (40)
end if
Sprite.Animate (BombWalkL, BwalkLeft (1), xPositionBomb, yPositionBomb, false)
elsif
xPositionTank + Pic.Width (TankWalkR ) > xPositionBomb then
put "AN ATROCIOUS HELLSCAPE HAS EMERGED!!!"
exit
end if
delay (10)
end loop
|
Please specify what version of Turing you are using
Turing 4.1.1 |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Zren
![](http://compsci.ca/v3/uploads/user_avatars/1110053965512db6185954b.png)
|
Posted: Sun Oct 13, 2013 10:57 pm Post subject: Re: Relatively New : Pic.Width Incompatability (Invalid Pic ID) with Sprites |
|
|
Virtuosity of Inaction @ Sun Oct 13, 2013 10:34 pm wrote: What is it you are trying to achieve?
I am trying to program (admittedly miserably, with flogging hopes) an actuator or mechanism to perform the action of spatially manipulating a doublet of separate objects along the x-axis, abiding by the policy of a stipulated condition defined by the "if" operator and operands, in the context of Sprite animations. The stipulation is qualitatively straight-forward or conceptually simple in the framework of my objective : objects are moved by the user and when the objects coincide or collide, the images change and an appropriate message is displayed to the user.
... *woosh*
Quote:
What is the problem you are having?
As indicated or suggested in the title, I am experiencing difficulties with configuring the stipulations to define a coincidence event in the interaction of the user with the spatial objects. In the below code, you will see "if" conditionals (e.g. if xPositionTank < 600 then and not xPositionTank + Pic.Width (TankWalkR) > xPositionBomb then"). However, when I run the program, the program returns the error notification, "Invalid Pic ID", causing my program to misbehave or malfunction.
code: |
var TankWalkR := Sprite.New (TwalkRight (1))
Pic.Width (TankWalkR)
|
Sprite.New() returns an integer which represents a sprite id. The parameter for Sprite.New() requires an integer representing a picture id. The parameter for Pic.Width() requires an integer representing a picture id.
Sprite id != picture id.
Both ids are represented by integers, which is why there's no compile time errors. Though just because there's a picture with an id of 234 doesn't mean there's a sprite with that id. |
|
|
|
|
![](images/spacer.gif) |
DemonWasp
|
Posted: Sun Oct 13, 2013 11:03 pm Post subject: RE:Relatively New : Pic.Width Incompatability (Invalid Pic ID) with Sprites |
|
|
I think your problem is that you're calling Pic.Width and giving it a sprite ID rather than a picture ID (they are not interchangeable).
Also, are you trying to sound like this: http://www.smbc-comics.com/index.php?db=comics&id=2295 ? |
|
|
|
|
![](images/spacer.gif) |
Raknarg
![](http://compsci.ca/v3/uploads/user_avatars/3745510004d8be6689b92f.jpg)
|
Posted: Sun Oct 13, 2013 11:43 pm Post subject: RE:Relatively New : Pic.Width Incompatability (Invalid Pic ID) with Sprites |
|
|
"I have a tank and if it crashes into the bomb it should explode". Just as easy to say, muchmore understandable (assuming I'm interpreting that correctly) |
|
|
|
|
![](images/spacer.gif) |
Virtuosity of Inaction
|
Posted: Mon Oct 14, 2013 7:14 pm Post subject: Re: Relatively New : Pic.Width Incompatability (Invalid Pic ID) with Sprites |
|
|
Thanks for the help!
I understand how the wording of my post was overcomplicated, but I do not cede obscurantism, especially not by aid of the thesaurus. If you need to know and clarification is in order, the aforementioned is how I normally speak, unless I am attending to the likes of infants. |
|
|
|
|
![](images/spacer.gif) |
Raknarg
![](http://compsci.ca/v3/uploads/user_avatars/3745510004d8be6689b92f.jpg)
|
Posted: Mon Oct 14, 2013 7:46 pm Post subject: RE:Relatively New : Pic.Width Incompatability (Invalid Pic ID) with Sprites |
|
|
OK. I'm just saying you're going to come off in the wrong way (and you kindof are now, I'd appreciate you not insinuating that my speech is comparable to what you would use for an infant), and people are going to have a hard time understanding you.
And no problem, come back any time. |
|
|
|
|
![](images/spacer.gif) |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: Mon Oct 14, 2013 8:16 pm Post subject: Re: Relatively New : Pic.Width Incompatability (Invalid Pic ID) with Sprites |
|
|
Virtuosity of Inaction @ Mon Oct 14, 2013 7:14 pm wrote: Thanks for the help!
I understand how the wording of my post was overcomplicated, but I do not cede obscurantism, especially not by aid of the thesaurus. If you need to know and clarification is in order, the aforementioned is how I normally speak, unless I am attending to the likes of infants.
Yeah, I'm not buying that. If wording your messages this way makes you feel intellectual or brilliant, that's fine, but that really isn't the response you're effecting. Whether this is how you speak in real life or not, it would benefit everyone for you to word your posts clearly and concisely. I for one didn't bother to help purely because I didn't want to expend the effort to read your post, which could have been one sentence long. |
|
|
|
|
![](images/spacer.gif) |
Amailer
![](http://compsci.ca/wiki/images/1/19/Avatar.jpg)
|
Posted: Mon Oct 14, 2013 9:10 pm Post subject: RE:Relatively New : Pic.Width Incompatability (Invalid Pic ID) with Sprites |
|
|
Sorry I don't mean to hijack this topic but I enjoyed the OP's post, it was a fun read, just wanted to say that.
Probably isn't the best way to ask for help though.
Carry on. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
|
|