C++ Programmer's Profile
Reputation: 20
Tradesman
- Group:
- Contributors
- Active Posts:
- 545 (0.3 per day)
- Joined:
- 12-June 08
- Profile Views:
- 11,524
- Last Active:
May 12 2013 05:18 PM- Currently:
- Offline
Previous Fields
- Country:
- US
- OS Preference:
- Linux
- Favorite Browser:
- FireFox
- Favorite Processor:
- Intel
- Favorite Gaming Platform:
- Classic
- Your Car:
- Who Cares
- Dream Kudos:
- 75
Latest Visitors
-
kirkdavid38 
02 May 2013 - 14:55 -
Zereo 
29 Apr 2013 - 07:33 -
makeitloud 
23 Apr 2013 - 12:54 -
CS2012 
04 Feb 2013 - 18:49 -
AthenaDX 
12 Nov 2012 - 14:52
Posts I've Made
-
In Topic: Comparing of 2 arrays
Posted 25 Apr 2013
Are you trying to compare the entire arrays? By this I mean are you trying to see if the arrays have identical elements in them or are you trying to see if certain elements of each array are the same? -
In Topic: Calling Class Function from Another
Posted 23 Apr 2013
Player* player = new Player();
Not only is there no delete for player so this is a memory leak, but you lose scope of the pointer after the initialize function. When trying to use the player pointer inside your RenderFrame function, player is not defined. To fix this, make the Player pointer a class member. Just as you did with window, then adapt the code inside your Initialize function to match how you did it for window. I hope you understand what I mean without me telling you exactly what to do or give you code. Let me know if I need to clarify anything. -
In Topic: Problem using characters in an array
Posted 24 Oct 2012
Please post your updated code so I can take a look. -
In Topic: Problem using characters in an array
Posted 24 Oct 2012
Remember, an array with size n has indexes from 0 to n - 1. So, your for loop shouldn't be going from 1 to 5, it should be going from 0 to 4. Also, in your for loop when you are inputting the value the user entered into the array, you don't use just the name, you must specify an index. This is where the for loop comes in, it keeps track of which index you are on, which is stored in the variable i.
Looking at your test function, you obviously understand that arrays start at 0 and go to n - 1 and you also understand how to use the [] operator. Use this to fix your for loop in the main method.
I realize that I am not the best at explaining things, but I hope that my post helped you
-
In Topic: Problem with top down shooter looking angle
Posted 28 Jun 2012
I have fixed this problem, I am sorry that I didn't post back faster. The problem was that SFML sets the origin of the rectangle at the top left, so when I called setRotate(), it used those as the origin. I used the setOrigin function to the center position so that it would rotate with the pivot as the center. This fixed the problem
Here is the updated Player's update function, because the whole thing isn't needed.
void Player::update(float timeStep) { if (m_window) { sf::Vector2f velocity = sf::Vector2f(0.f, 0.f); if (sf::Keyboard::isKeyPressed(sf::Keyboard::W)) velocity.y = -m_speed; if (sf::Keyboard::isKeyPressed(sf::Keyboard::S)) velocity.y = m_speed; if (sf::Keyboard::isKeyPressed(sf::Keyboard::D/>)) velocity.x = m_speed; if (sf::Keyboard::isKeyPressed(sf::Keyboard::A)) velocity.x = -m_speed; m_position.x += velocity.x * timeStep; m_position.y += velocity.y * timeStep; m_rect.setPosition(m_position); sf::Vector2i mouse = sf::Mouse::getPosition(*m_window); sf::Vector2f mouse_position = m_window->convertCoords(mouse); sf::Vector2f angle = mouse_position - m_position; m_angle = atan2(angle.y, angle.x); m_angle *= 180.f / PI; //cout << m_angle << endl; m_rect.setRotation(m_angle); } }
Thank you for the help though
My Information
- Member Title:
- D.I.C Addict
- Age:
- 23 years old
- Birthday:
- January 24, 1990
- Gender:
-
- Location:
- My Computer
- Interests:
- Programming/Scripting/Game Development
- Full Name:
- Kevin Bacon
- Years Programming:
- 6
- Programming Languages:
- C++, C#, Win32 API, PHP, HTML, CSS, Java, JavaScript, Batch, Blitz
Contact Information
- E-mail:
- Click here to e-mail me
- AIM:
-
drag0nsrreal
- MSN:
-
staplesarereal@hotmail.com
- Website URL:
-
http://www.google.com/
|
|


Find Topics
Find Posts
View Reputation Given
|
Comments
ManCave
13 Jun 2012 - 14:46inder1757
18 Dec 2011 - 23:41byhiey
07 Nov 2011 - 07:30Syrrus
01 Dec 2010 - 00:40C++ Programmer
30 Jul 2010 - 11:06bubbles06
29 Jul 2010 - 17:11