
-----------------------------------
VietUnity
Wed Jan 13, 2010 10:51 am

Images
-----------------------------------
I was wondering if there was a way to ust remove a single picture?

I am trying to make a super smash like game, but can't get the picture replaced by another when i click a movement key.

I have tried using Pic.ScreenSave.

I am using Turing 4.1.1 or 4.1, i have both.

-----------------------------------
Ktomislav
Wed Jan 13, 2010 11:30 am

Re: Images
-----------------------------------
The best way is to clear screan with cls and then draw all pictures except that one.

-----------------------------------
VietUnity
Wed Jan 13, 2010 5:49 pm

Re: Images
-----------------------------------
But doing that creates a white flash, since I then have to keep drawing the stage.

And another question, how would i make the character attack in a different direction using the same key?
example, facing left, pressing the "a" key causes a punch in the right direction, but pressing the "a" key while facing left cause it to punch in the left direction.

-----------------------------------
Ktomislav
Wed Jan 13, 2010 6:03 pm

Re: Images
-----------------------------------
To fix the white flash use View.Update.

And for attacking in different directions:
Store your direction in a variable.
Then check if direction = "left" draw the character punching left.
Something like that.

-----------------------------------
TheGuardian001
Wed Jan 13, 2010 6:07 pm

Re: Images
-----------------------------------
But doing that creates a white flash, since I then have to keep drawing the stage.

Which is where the magics of double buffering and once within a single section of the program. For example this:

And another question, how would i make the character attack in a different direction using the same key?
example, facing left, pressing the "a" key causes a punch in the right direction, but pressing the "a" key while facing left cause it to punch in the left direction.


with a combination of if statements and having separate procedures for each punch direction, for example
[code]
if a_key_pressed then   %Player wants to punch!
    if player_facing_left then %If they were facing left at the time
        player_punch_left    %then they should punch to the left
    elsif player_facing_right then %Or if they were facing right,
        player_punch_right  %they should punch to the right.
    end if
end if
[/code]

-----------------------------------
VietUnity
Wed Jan 13, 2010 9:36 pm

Re: Images
-----------------------------------
Here is what i have so far, not quite sure where i would put the setscreen (offscreenonly").

-----------------------------------
TheGuardian001
Wed Jan 13, 2010 11:06 pm

Re: Images
-----------------------------------
as a rule of thumb, any setscreen line should be at the very start of your program, unless you intend to change the window properties mid program.

Technically it will work anywhere though. It's just normally put at the start to ensure the window acts in that way right away.

-----------------------------------
VietUnity
Wed Jan 13, 2010 11:42 pm

Re: Images
-----------------------------------
There is the problem of it not drawing the movement images if I us the setscreen ("offscreenonly").

-----------------------------------
Turing_Gamer
Thu Jan 14, 2010 8:43 am

Re: Images
-----------------------------------
I havn't opened the file cause I can't but generally when you start all the graphics stuff, have a View.Set ("offscreenonly").
Or even better, a double buffer for better graphics.
View.Set ("graphics:maxx;maxy;offscreenonly")

-----------------------------------
TheGuardian001
Thu Jan 14, 2010 8:47 am

Re: Images
-----------------------------------

There is the problem of it not drawing the movement images if I us the setscreen ("offscreenonly").



 This means that the user won't see anything that you draw until you call View.Update.

This include stuff in procedures. View.Update should be called whenever you want the screen to update. Technically, you shouldn't be drawing the movement pics the way you do, as they block anything else from happening while they're drawing.
Also, constantly loading and reloading the images is pointless just load them all at the start of your program instead of reloading them every time.

-----------------------------------
VietUnity
Thu Jan 14, 2010 10:08 am

Re: Images
-----------------------------------
So, your saying to have a bunch of variables for each image?

-----------------------------------
TheGuardian001
Thu Jan 14, 2010 10:18 am

Re: Images
-----------------------------------
No, I'm saying to only load the images once. In your procedures, you have

once at the start, instead of loading every single time the procedure is run, freeing it, then loading again next time.

-----------------------------------
VietUnity
Thu Jan 14, 2010 10:49 am

Re: Images
-----------------------------------
Yeah, but doing that also requires the use of multiple variables, right?

-----------------------------------
Turing_Gamer
Thu Jan 14, 2010 11:58 am

Re: Images
-----------------------------------
No, when you are changing picture positions, you change the variable of that picture
If you are swaping pictures, you change the picure but keep the varables like so...
var norm : int := Pic.FileNew ("German Soldier.bmp")
var normsl : int := Pic.FileNew ("German Soldier Shooting Left.bmp")
var xnorm : int := 100
var ynorm : int := 100
%%%
if command = 'a' then
    Pic.Draw (normsl, xnorm, ynorm, picCopy)
else
    Pic.Draw (norm, xnorm, ynorm, picCopy)
end if

-----------------------------------
VietUnity
Thu Jan 14, 2010 4:34 pm

RE:Images
-----------------------------------
yeah thats what i ment, having to use different variables for loading each picture.

-----------------------------------
TheGuardian001
Thu Jan 14, 2010 4:47 pm

Re: Images
-----------------------------------
That's what you should be doing, all the time. you should never have only one variable to hold all of your images. You're better off having multiple variables than constantly loading them in.

-----------------------------------
Turing_Gamer
Thu Jan 14, 2010 6:15 pm

Re: Images
-----------------------------------
Each picture, as far as I know, has to be a different variable but the positioning system has to be the same

-----------------------------------
iii
Thu Jan 14, 2010 11:38 pm

Re: Images
-----------------------------------
View.Update should only ever be called once within a single section of the program. 

Is that still true if you're using if else?

-----------------------------------
Zren
Thu Jan 14, 2010 11:53 pm

Re: Images
-----------------------------------
View.Update should only ever be called once within a single section of the program. 

Is that still true if you're using if else?
And putting it after the if/else statement wouldn't work how? After all, both conditions [assumingly] will make you update the screen.

-----------------------------------
Turing_Gamer
Fri Jan 15, 2010 8:40 am

Re: Images
-----------------------------------
He means like this...
loop
    %%%RANDOM CODE%%%
    if leftpunch := true then
        Pic.Draw (left, x, y, picCopy)
    elsif leftpunch := false then
        Pic.Draw (normal, x, y, picCopy)
    end if
    View.Update
end loop

-----------------------------------
TheGuardian001
Fri Jan 15, 2010 8:47 am

Re: Images
-----------------------------------

Is that still true if you're using if else?

As others said, you can simply put it after the if statement, however for the record yes, it is still true. The whole point of double buffering (offscreenonly) is that you only ever draw one thing to the screen, meaning you avoid the flickering caused by drawing being done at different times.

If you use View.Update more than once per section of code, you're defeating the purpose of using it at all, since you will be drawing multiple times and, if you do it often enough, flickering again.

-----------------------------------
VietUnity
Wed Jan 20, 2010 9:38 pm

RE:Images
-----------------------------------
Would it be possible for me to use the Sprite commands? for example use Sprite.Hide to hide the standing picture during the actions and hide the action pictures when the character is standing.

-----------------------------------
apomb
Thu Jan 21, 2010 9:38 am

RE:Images
-----------------------------------
Just as a side note, Chrome doesnt like me viewing this thread because one of the previous poster's avtars is hosted on fractalized.ca which is known to host malware.
