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

Username:   Password: 
 RegisterRegister   
 Images
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
VietUnity




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
Ktomislav




PostPosted: 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.
VietUnity




PostPosted: 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.
Ktomislav




PostPosted: 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.
TheGuardian001




PostPosted: 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
code:

setscreen("offscreenonly")

at the start of your program.

View.Update should only ever be called once within a single section of the program. For example this:
code:

loop
    draw_oval   %draw stuff
    View.Update%update screen
    draw_box    %draw stuff
    View.Update%update
    draw_maple_leaf %draw stuff
    View.Update %update
    cls %clear the current offscreen image
end loop

is wrong. This:
code:

loop
    draw_oval %draw stuff
    draw_box %draw stuff
    draw_maple_leaf %draw stuff
    View.Update %everything has been drawn, update now
    cls %clear the current offscreen image.
end loop

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
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
VietUnity




PostPosted: 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").


Final Game.rar
 Description:

Download
 Filename:  Final Game.rar
 Filesize:  1.34 MB
 Downloaded:  74 Time(s)

TheGuardian001




PostPosted: 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.
VietUnity




PostPosted: 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").
Sponsor
Sponsor
Sponsor
sponsor
Turing_Gamer




PostPosted: 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.
Turing:
View.Set ("graphics:maxx;maxy;offscreenonly")
TheGuardian001




PostPosted: 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.
VietUnity




PostPosted: Thu Jan 14, 2010 10:08 am   Post subject: Re: Images

So, your saying to have a bunch of variables for each image?
TheGuardian001




PostPosted: 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

code:

proc example
    my_image = load_image
    draw_image (my_image)
    pic_free(my_image)
end example

loop
example
end loop


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

code:

my_image = load_image

proc example
    draw_image
end example

loop
    example
end loop


Load each image once at the start, instead of loading every single time the procedure is run, freeing it, then loading again next time.
VietUnity




PostPosted: Thu Jan 14, 2010 10:49 am   Post subject: Re: Images

Yeah, but doing that also requires the use of multiple variables, right?
Turing_Gamer




PostPosted: 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...
Turing:
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




PostPosted: 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.
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 2  [ 23 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: