Computer Science Canada Images |
Author: | VietUnity [ Wed Jan 13, 2010 10:51 am ] |
Post subject: | 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. |
Author: | Ktomislav [ Wed Jan 13, 2010 11:30 am ] |
Post subject: | Re: Images |
The best way is to clear screan with cls and then draw all pictures except that one. |
Author: | VietUnity [ Wed Jan 13, 2010 5:49 pm ] |
Post subject: | 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. |
Author: | Ktomislav [ Wed Jan 13, 2010 6:03 pm ] |
Post subject: | 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. |
Author: | TheGuardian001 [ Wed Jan 13, 2010 6:07 pm ] | ||||||||
Post subject: | Re: Images | ||||||||
VietUnity @ Wed Jan 13, 2010 5:49 pm wrote: 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 View_update come in handy. using offscreen drawing will draw everything offscreen, instead of in your window. This means that the user won't see anything that you draw until you call View.Update. View.Update will then take everything that you have drawn offscreen and draw it onscreen as a single image, preventing that nasty flickering. You can enable offscreen drawing by including
at the start of your program. View.Update should only ever be called once within a single section of the program. For example this:
is wrong. This:
is right. VietUnity wrote: 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
|
Author: | VietUnity [ Wed Jan 13, 2010 9:36 pm ] |
Post subject: | Re: Images |
Here is what i have so far, not quite sure where i would put the setscreen (offscreenonly"). |
Author: | TheGuardian001 [ Wed Jan 13, 2010 11:06 pm ] |
Post subject: | 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. |
Author: | VietUnity [ Wed Jan 13, 2010 11:42 pm ] |
Post subject: | Re: Images |
There is the problem of it not drawing the movement images if I us the setscreen ("offscreenonly"). |
Author: | Turing_Gamer [ Thu Jan 14, 2010 8:43 am ] | ||
Post subject: | 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.
|
Author: | TheGuardian001 [ Thu Jan 14, 2010 8:47 am ] |
Post subject: | Re: Images |
VietUnity wrote: There is the problem of it not drawing the movement images if I us the setscreen ("offscreenonly"). TheGuardian001 wrote: 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. |
Author: | VietUnity [ Thu Jan 14, 2010 10:08 am ] |
Post subject: | Re: Images |
So, your saying to have a bunch of variables for each image? |
Author: | TheGuardian001 [ Thu Jan 14, 2010 10:18 am ] | ||||
Post subject: | Re: Images | ||||
No, I'm saying to only load the images once. In your procedures, you have
this means that every single time the procedure is run, you will load the image over again, which is very inefficient. What you should be doing is something more like
Load each image once at the start, instead of loading every single time the procedure is run, freeing it, then loading again next time. |
Author: | VietUnity [ Thu Jan 14, 2010 10:49 am ] |
Post subject: | Re: Images |
Yeah, but doing that also requires the use of multiple variables, right? |
Author: | Turing_Gamer [ Thu Jan 14, 2010 11:58 am ] | ||
Post subject: | 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...
|
Author: | VietUnity [ Thu Jan 14, 2010 4:34 pm ] |
Post subject: | RE:Images |
yeah thats what i ment, having to use different variables for loading each picture. |
Author: | TheGuardian001 [ Thu Jan 14, 2010 4:47 pm ] |
Post subject: | 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. |
Author: | Turing_Gamer [ Thu Jan 14, 2010 6:15 pm ] |
Post subject: | Re: Images |
Each picture, as far as I know, has to be a different variable but the positioning system has to be the same |
Author: | iii [ Thu Jan 14, 2010 11:38 pm ] |
Post subject: | Re: Images |
Quote: 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? |
Author: | Zren [ Thu Jan 14, 2010 11:53 pm ] |
Post subject: | Re: Images |
iii @ Thu Jan 14, 2010 11:38 pm wrote: Quote: 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. |
Author: | Turing_Gamer [ Fri Jan 15, 2010 8:40 am ] | ||
Post subject: | Re: Images | ||
He means like this...
|
Author: | TheGuardian001 [ Fri Jan 15, 2010 8:47 am ] |
Post subject: | Re: Images |
iii @ Thu Jan 14, 2010 11:38 pm wrote: 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. |
Author: | VietUnity [ Wed Jan 20, 2010 9:38 pm ] |
Post subject: | 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. |
Author: | apomb [ Thu Jan 21, 2010 9:38 am ] |
Post subject: | 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 ********.ca which is known to host malware. |