Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - sofakng

Pages: [1] 2
1
Graphics / How can I resize my view when my window size changes but...
« on: February 16, 2009, 07:16:42 pm »
Anybody have any clues about this...? :(

2
Graphics / How can I resize my view when my window size changes but...
« on: February 12, 2009, 01:13:21 pm »
Unfortunately, yes :(

3
Graphics / How can I resize my view when my window size changes but...
« on: February 11, 2009, 11:15:09 pm »
Hmmm, I'm really at a loss here.

Here is the code for when my window resizes:

Code: [Select]

         Dim cameraX As Single = m_renderWindow.CurrentView.Center.X
         Dim cameraY As Single = m_renderWindow.CurrentView.Center.Y

         m_renderWindow.CurrentView.SetFromRect(New FloatRect(pnlRenderWindow.ClientRectangle.Left, pnlRenderWindow.ClientRectangle.Top, pnlRenderWindow.ClientRectangle.Right, pnlRenderWindow.ClientRectangle.Bottom))
         m_renderWindow.CurrentView.Center = New Vector2(cameraX, cameraY)


As you can see, I'm grabbing the CurrentView.Center and storing it, then resizing the CurrentView using SetFromRect.  (pnlRenderWindow.ClientRectangle is client size [eg. rendering area] of my Windows forms panel that I'm drawing onto).

After that, I'm setting the new CurrentView's center to what it was previously.

Here is a screenshot of what I'm referring to:

Before resizing (looks perfect):


After resizing (notice the artifacts [?] on the black lines)


Also, notice that the CurrentView.Center is set to a fractional size in both the "good" and "bad" screenshots.  The only thing that changed is the form size (displayed as Form: in the statusbar of the screenshots)

4
Graphics / How can I resize my view when my window size changes but...
« on: February 11, 2009, 07:52:28 pm »
I'm not sure what you mean...

If I moved -100 units on the X, then -50, then -25, that would be -175 total for the X.

Are you saying to manually keep track of everytime I call Move() and then after resizing my window call it again with my totals?

It seems like storing View.Center and then re-assigning it works exactly like I'd want but I am having a strange problem.

With certain Center values and FloatRect (for the view) my sprites are drawn very jagged.  I'm still trying to diagnose what exactly values are making this happen though...

EDIT: Could it be because I'm using floating point values (eg. 270.5) for the View.Center variable?

5
DotNet / How can I convert SFML.Graphics.Image to System.Drawing.Imag
« on: February 10, 2009, 05:25:29 pm »
Yeah, I noticed SFML.Graphics.Image.Pixels() but I can't seem to figure out how to store it into a System.Drawing.Image.Bitmap (which is apparantly what I need to do).  You can't instantiate a System.Drawing.Image directly so I'm guessing I need a bitmap...

6
DotNet / How can I convert SFML.Graphics.Image to System.Drawing.Imag
« on: February 10, 2009, 03:17:57 pm »
I'm drawing to load a bunch of images using SFML.Graphics.Image and then display them in a System.Windows.Forms.ImageList object.

However, this object requires images to be System.Drawing.Image.

How can I convert from SFML.Graphics.Image to System.Drawing.Image?

Thanks for any help!

7
Graphics / How can I resize my view when my window size changes but...
« on: February 07, 2009, 04:53:19 am »
Let's say I have a window with a size of 200x200.  Let's now say I did a RenderWindow.CurrentView.Move(-100, 100) so that (0, 0) is now drawn at the center of my screen.

Now let's say I resize my window to 400x400.  I'm able to create a new view with the correct size (400x400) but I want my view to stay centered on the same spot as before.  I want everything my new view to show screen space around the center of the screen.

For some reason I just can't think this through but it seems to make sense.  If I enlarge my game window I want to see more of the game but the center of my display shouldn't change.

(NOTE: I know in most games that resizing the window doens't allow you to see more but for my game this makes sense...)

Thanks for any help.

8
Graphics / View.Move() - How does it work? (eg. it moves in "unit
« on: February 07, 2009, 04:24:30 am »
Thanks for the reply!  I was able to figure out what I was doing wrong...

9
Graphics / View.Move() - How does it work? (eg. it moves in "unit
« on: January 30, 2009, 05:57:18 pm »
I'm a little confused on View.Move() and how it works.  The help file says it "moves the view" and the online tutorial says that it moves the view by X "units".  What does that mean?

Does it move the view by X number of pixels?  (eg. scroll the view)

I've tried m_renderWindow.DefaultView.Move(10, 0) and thought it would scroll my view to the right but instead it seems to scroll downward.

Also, I'm just curious but why is there a HalfSize and not just a Size variable? :)

10
DotNet / Bug with line drawing? Shouldn't it go from p1 to p2? (easy)
« on: January 28, 2009, 06:37:57 pm »
Darn floats.  They always cause problems! :)

The reason I found this bug was because I'm trying to draw isometric tiles using the SFML drawing functions but the sides of the tile do not line-up correctly.  I guess it's a little confusing because OpenGL and Flash both seem to render the lines "correctly" (but I suppose correct is a relative term).

I might be able to use pre-generated sprites so my lines are always correct but I was hoping to use the drawing functions for other purposes as well.

11
DotNet / Bug with line drawing? Shouldn't it go from p1 to p2? (easy)
« on: January 28, 2009, 05:53:14 pm »
Thanks for the quick response.

Upon further testing, drawing a line directly through OpenGL produces yet another different result but this one seems to be correct.

Here are screenshots:

Line drawn with SFML:


Line drawn with SFML plus sprite (notice the sprite is after the line):


Line drawn with OpenGL (red) on top of SFML line (white):

12
DotNet / Bug with line drawing? Shouldn't it go from p1 to p2? (easy)
« on: January 28, 2009, 05:14:52 pm »
Here's what I'm doing:

1) Drawing a line from (0, 0) to (11, 10).
2) Drawing a 1x1 sprite at (11, 10).

However, the sprite is drawn AFTER the end of the line.  In other words, the line is not ending at (11, 10).

What's going on here?

Here is my code:

Code: [Select]
     ' Define points
      Dim p1 As Vector2 = New Vector2(0, 0)
      Dim p2 As Vector2 = New Vector2(11, 10)

      ' Create and draw the line
      Dim line As SFML.Graphics.Shape = SFML.Graphics.Shape.Line(p1, p2, 1, White)
      m_renderWindow.Draw(line)

      ' Create and draw the sprite
      Dim sprite As Sprite = New Sprite(New Image("tiles\1x1.bmp"))
      sprite.Position = p2
      m_renderWindow.Draw(sprite)

13
General discussions / How could I implement a fixed-timestep game loop?
« on: January 16, 2009, 05:11:22 pm »
Thanks for the reply.

I think I wasn't that clear in my original question.

My actual goal is to seperate my update logic from my display/render logic.

For example, I think XNA does it perfectly: http://blogs.msdn.com/shawnhar/archive/2007/11/23/game-timing-in-xna-game-studio-2-0.aspx

However, in order for me to implement that I need to know how GetFrameTime() is working.

By seperating the update and render logic you can render as fast as possible (200+ FPS) while the update logic runs slower if needed.  That way the user gets a very good framerate without sacrificing update speed.

14
General discussions / How could I implement a fixed-timestep game loop?
« on: January 16, 2009, 03:22:25 pm »
Has anybody implemented a fixed-timestep game loop with SFML?

Also, I have a couple of questions about GetFrameTime():

1) What type of performance counter does GetFrameTime use?  How accurate is it?

2) What time frame does it measure?  (eg. does it measure the time from the end of Display() to the start of the next call to Display()?)

Thanks for any help!

15
DotNet / Font.GetImage doesn't exist? Problem with .NET port?
« on: January 14, 2009, 11:41:00 pm »
Sounds good.  I look forward to the updates!

By the way, will this render-to-image allow games like Worms or Scorched earth?  They usually require modifying a bitmap/image every frame to simulate terrain destruction, etc.

However, I'm not sure how fast this will be since modifying textures in video memory is supposedly a very expensive operation.

Pages: [1] 2
anything