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

Author Topic: im completely lost on Camera movement in SFML C#  (Read 2436 times)

0 Members and 1 Guest are viewing this topic.

Geoffry_the_Deprogrammer

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
im completely lost on Camera movement in SFML C#
« on: August 22, 2014, 04:39:47 am »
I cant seem to figure out how to make the camera move, ive read tutorials etc. and im lost... if i simply wanted to move the camera up, upon the press of the "W" key, what code do i need, and which class should i put it in...?

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: im completely lost on Camera movement in SFML C#
« Reply #1 on: August 22, 2014, 05:24:47 am »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: im completely lost on Camera movement in SFML C#
« Reply #2 on: August 22, 2014, 08:38:07 am »
Not sure what you mean by "Camera" class, SFML's "camera" is the view and if you really read the linked tutorial, I'm not sure how you've missed the "Moving (scrolling) the view" with the example code:

// move the view by an offset of (100, 100) (so its final position is (300, 300))
view.move(100, 100);
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Ztormi

  • Jr. Member
  • **
  • Posts: 71
  • Web developer by day. Game developer by night.
    • View Profile
Re: im completely lost on Camera movement in SFML C#
« Reply #3 on: August 22, 2014, 12:52:36 pm »
In your update method, do:

 
                if (Keyboard.IsKeyPressed(Keyboard.Key.W))
                {
                    View view = window.GetView();
                    view.Move(new Vector2f(0, -1));
                    window.SetView(view);
                }

Remember to set the modified view for window!

Geoffry_the_Deprogrammer

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Re: im completely lost on Camera movement in SFML C#
« Reply #4 on: August 25, 2014, 12:15:49 am »
In your update method, do:

 
                if (Keyboard.IsKeyPressed(Keyboard.Key.W))
                {
                    View view = window.GetView();
                    view.Move(new Vector2f(0, -1));
                    window.SetView(view);
                }

Remember to set the modified view for window!

Thanks, this makes sense...   :)

 

anything