Jdfskitz

Member
  • Content count

    11
  • Joined

  • Last visited

Community Reputation

105 Neutral

About Jdfskitz

  • Rank
    Member
  1. both. I originally had 3 cases but I switched it to try and just get a half of the system working at least but failed. can you show me how I might properly initialize it? sorry, I'm fairly new to SFML and my C++ knowledge is kinda well, Everywhere. this is certainly teaching me the use of pointers finally though, hard as heck to understand from the books demonstrations for C++, but I can't really figure this one out :\ I suppose I may be able to go about this a different route.   instead of using ball->move(x,y);   I could use ball->setPosition(x++,y++) || (x--,y--);   I'm not even attempting for the randomness right now. All I am trying to achieve is a bounce.
  2.     #include "Engine.h" //Screen Resolution properties for proper values among positioning for renders. sf::Vector2f Screen = sf::Vector2f(800,600); //************************Constructor**************************** Engine::Engine() { // } //************************Deconstructor**************************** Engine::~Engine() { // } //************************What is rendered upon initialization**************************** bool Engine::init() { //Point to the window and create one for our use. window = new sf::RenderWindow(sf::VideoMode(Screen.x,Screen.y,32), "Pong"); //Define the player Shapes defineShapes(); //if the window fails return a negative response if(!window) return false; //else continue return true; } //************************Determine what keys perform Events**************************** void Engine::ProcessEvents() { sf::Event event; //perform Events while the window is open. while(window->pollEvent(event)) { switch(event.type) { //Upon the selection of the close buttons on a window Close the window case sf::Event::Closed: window->close(); break; //upon a Key that is pressed close the window case sf::Event::KeyPressed: if(event.key.code == sf::Keyboard::Escape) window->close(); break; } } //--------------------------Call upon player Functions--------------------------- //movement settings for the first rectangle on the Left movePlayerOne(); //movement settings for the Second rectangle on the Right movePlayerTwo(); //Determine Collison factor and move the ball movCollision(); } //************************Draw to the Screen [Update]**************************** void Engine::Update() { //clear the window window->clear(sf::Color(40,40,40)); //draw the first rectangle on the Left window->draw(*playerOne); //draw the Second rectangle on the Right window->draw(*playerTwo); //draw the Ball in the Center window->draw(*Ball); } //************************Window Display Settings**************************** void Engine::RenderFrame() { window->display(); } //************************Determine the actions after Start**************************** void Engine::Main() { while(window->isOpen()) { ProcessEvents(); Update(); RenderFrame(); } } //************************Start the Engine**************************** void Engine::Go() { //if it doesn't initialize send an error message if(!init()) throw "Could not initialize game loop"; //continue to main loop Main(); } //************************Movement for Player One**************************** void Engine::movePlayerOne() { //set the speed of the player int speed = 10000; //Create a clock sf::Clock clock; //Restart the clock clock.restart(); //if W is pressed on the keyboard move Up if(sf::Keyboard::isKeyPressed(sf::Keyboard::W)) { playerOne->move(0,clock.getElapsedTime().asSeconds() * -speed); } //if S is pressed on the Keyboard move Down if(sf::Keyboard::isKeyPressed(sf::Keyboard::S)) { playerOne->move(0,clock.getElapsedTime().asSeconds() * speed); } } //************************Movement for Player Two**************************** void Engine::movePlayerTwo() { //set the speed of the player 2 int speed = 10000; //Create another clock sf::Clock clock; //Restart the clock clock.restart(); //if Up is pressed on the Keyboard Move Up if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) { playerTwo->move(0,clock.getElapsedTime().asSeconds() * -speed); } //if Down is pressed on the Keyboard Move Down if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) { playerTwo->move(0,clock.getElapsedTime().asSeconds() * speed); } } //************************Begin Defining Shapes**************************** void Engine::defineShapes() { //Define Player One Rectangle playerOne = new sf::RectangleShape(); //Set the Player One Rectangle Size playerOne->setSize(sf::Vector2f(16,64)); //Set the Player One Rectangle Color playerOne->setFillColor(sf::Color(255,255,255,255)); //Set the Player One Rectangle Position playerOne->setPosition(sf::Vector2f(40,20)); //Define Player Two Rectangle playerTwo = new sf::RectangleShape(); //Set the Player Two Rectangle Size playerTwo->setSize(sf::Vector2f(16,64)); //Set the Player Two Rectangle Color playerTwo->setFillColor(sf::Color(255,255,255,255)); //Set the Player Two Rectangle Position playerTwo->setPosition(sf::Vector2f(740,520)); //Define Ball Ball = new sf::RectangleShape(); //Set the Ball Size Ball->setSize(sf::Vector2f(16,16)); //Set the Ball Color Ball->setFillColor(sf::Color(0,255,0,255)); //Set the Ball Position Ball->setPosition(740, 520); } //************************Begin Defining Collision for the Ball and Players**************************** void Engine::movCollision() { //Store Player Positions into Vectors sf::Vector2f playerOnePosition = sf::Vector2f(playerOne->getPosition()); sf::Vector2f playerTwoPosition = sf::Vector2f(playerTwo->getPosition()); sf::Vector2f BallPosition = sf::Vector2f(Ball->getPosition()); //Define Rectangle around the players sf::IntRect playerOneRect(playerOnePosition.x,playerOnePosition.y, playerOne->getSize().x, playerOne->getSize().y); sf::IntRect playerTwoRect(playerTwoPosition.x,playerTwoPosition.y, playerTwo->getSize().x, playerTwo->getSize().y); sf::IntRect BallRect(BallPosition.x,BallPosition.y, Ball->getSize().x, Ball->getSize().y); //set the clock for speed sf::Clock clock; //Restart the clock clock.restart(); //determine position and velocity. sf::Vector2f pos; sf::Vector2f velocity; velocity.x = clock.getElapsedTime().asSeconds() * -12000; velocity.y = clock.getElapsedTime().asSeconds() * -600; //Detect Collison bool collisionPlayerTwo = BallRect.intersects(playerTwoRect); bool collisionPlayerOne = BallRect.intersects(playerOneRect); //If Collision  if(collisionPlayerTwo && !collisionPlayerOne) velocity.x = velocity.x; if(collisionPlayerOne && !collisionPlayerTwo) velocity.x = -velocity.x; pos += velocity; Ball->move(pos); }      
  3. Creating a Game Menu in Allegro(help)

    still not solved :\
  4. Creating a Game Menu in Allegro(help)

    the position where I think the issue is happening is now commented out.
  5. I can't figure it out, but I think at the end of the switch statement for the Menu it's not registering the fact that I declare gamemode as anything. I know it exits the switch statement because when I place the exit(1); command the program closes after hitting enter on the quit image. I haven't been able to improve my C++ very much lately and resulted to trying to learn allegro, and eventually when I am capable of it switching to SDL & OpenGL [CODE]#include <allegro.h> void mainMenu(); void playGame(); int gamemode; int main() { allegro_init(); install_keyboard(); set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0); clear_to_color(screen, makecol(100, 224, 100)); set_color_depth(32); gamemode = 1; do{ switch(gamemode) { case 0: playGame(); textout_ex(screen, font, "hello world", 20, 30, makecol(255,0,0), -1); break; case 1: mainMenu(); break; } }while(gamemode != 2); } END_OF_MAIN(); void mainMenu() { BITMAP *newgame, *quit; newgame = load_bitmap("newgame.bmp", NULL); quit = load_bitmap("quit.bmp", NULL); blit(newgame, screen, 0, 0, 0, 0, 230, 60); blit(quit, screen, 0, 0, 0, 60, 230, 60); int choice; choice = 0; int choicechosen; /* while(!key[KEY_ESC]) { do{ if(key[KEY_S])choice++; else if(key[KEY_W])choice--; while(choice >= 3) { choice--; } while(choice <= 0) { choice++; } switch(choice) { case 1: newgame = load_bitmap("newgamec.bmp", NULL); quit = load_bitmap("quit.bmp", NULL); blit(newgame, screen, 0, 0, 0, 0, 230, 60); blit(quit, screen, 0, 0, 0, 60, 230, 60); break; case 2: quit = load_bitmap("quitc.bmp", NULL); newgame = load_bitmap("newgame.bmp", NULL); blit(newgame, screen, 0, 0, 0, 0, 230, 60); blit(quit, screen, 0, 0, 0, 60, 230, 60); break; if(key[KEY_ENTER]) { choicechosen = choice; destroy_bitmap(newgame); destroy_bitmap(quit); } if(choicechosen == 1) { gamemode = 0; } rest(5); }while(choicechosen != 2); gamemode == choicechosen; if(choicechosen == 2) { exit(1); } } } */ void playGame() { } [/CODE]
  6. Python is simple (kinda), Java is similar to c++. :P from what I have seen. But. well, I just really want to stick to one language. I went to learn c++, people said do Java, I do Java. People say do Python, I do Python People say do Java. And it just went in a cycle for a long time.
  7. WoW! Thats a lot of comments! I've gone through engines. I dislike the unity GameEngine, I was looking at the Unreal Engine. I would really dislike to have to use pyhton or java first, because from what I remember, I tried using them and they were just like 1 + 1 = 2 OH THanks lol. I want a challenge. :P And I have already read a lot on c++. Just not the most I started wanting to learn how to code software when I was about 12. Now I am 16. I have been doing Html + css for a while. But thats barely even coding. Thank you for all of the tips!!!!!! I bet I could get it going pretty well now :). I need to work on what they said up there. Pointers, Functions, Classes, Etc. :P After I get all the basic functions memorized, I need to find a good reference book. And then learn some Graphics. I'm not sure If I should do SDL or OpenGL First. Most definitely not DirectX lol. I Haven't been testing and making goals of games to make or w/e with a reference or anything. Which would be a great Idea come to think of it :). Thanks Again!
  8. >> >> >> >> >>Go to channel wecanworkitout >> >>on the chatroom and we can talk there if you don't have msn
  9. ok, thankyou :P I have done quite a bit of learning the basics A while ago earlier this year I was coding this http://pastebin.com/KRw2r1hA but never finished When I can create a game similar to Zelda Ocarina of Time is when I know that I have reached my goal. I can do modeling similar to that. And yeah, maybe we can work together Labombadog. Do you have a form of msn? yahoo messenger? jdfskitz@hotmail.com jdfskitz@yahoo.com those are mine :P I use my Msn more. or we could use the chatroom up there? aren't we able to join our own rooms?
  10. Thankyou all for replying without being completely negative about it :) you have no Idea how long I have been looking for a website where people are mature about stuff and not like the guy from grandmas boy
  11. I have been looking for a forum that wasn't full of people unwilling to help you for a while. A few years I have been trying to find out how to code c++, possibly Java, But I prefer c++. I understand Java is similar and in some ways slightly easier, but it does networking better. Anyways. I have read many books probably over 800 pages of c++ books, and none of them have helped me. all I know pretty much is const int int string I always forget how to do vectors. c output c input cin cout I have pretty much given up over the last year and forgot how to do a lot. Even though I didn't learn much. I don't even remember how to start a function :\. My goal since the beginning was to be able to catch peoples eyes, and help them using Games, Software, or anything related. But so far the most I have done is make a word game where I forgot even this how to type a number and it prints words then gives you another choice of what to do. I know about object orientation because that is how my mind has worked for my entire life. All I ask, is if anyone can help. Where do I start, what books, what sites, What info do I need to tell you. I have been looking at nehegl. But I feel I am not ready for it. OpenGL is where I want to start in game programming, and then I want to move to DirectX. Any Suggestions?