Creating The Game Pong
Creating The Game Pong
Creating The Game Pong
Background: 800x600 px
Shapes
Menampilkan background game
//Libraries
#include <SFML/Graphics.hpp>
#include <iostream>
#include <SFML/Audio.hpp>
int main()
{
//Creating the window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Game");
window.setKeyRepeatEnabled(false);
//Libraries
#include <SFML/Graphics.hpp>
#include <iostream>
#include <SFML/Audio.hpp>
int main()
{
//Creating the window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Game");
window.setKeyRepeatEnabled(false);
int main()
{
//Creating the window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Game");
window.setKeyRepeatEnabled(false);
Shapes
Menambahkan pad 2 dan ball
Movement
Menggerakkan pad 1
//Libraries
#include <SFML/Graphics.hpp>
#include <iostream>
#include <SFML/Audio.hpp>
int main()
{
//Creating the window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Game");
window.setKeyRepeatEnabled(false);
//Libraries
#include <SFML/Graphics.hpp>
#include <iostream>
#include <SFML/Audio.hpp>
int main()
{
//Creating the window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Game");
window.setKeyRepeatEnabled(false);
//Libraries
#include <SFML/Graphics.hpp>
#include <iostream>
#include <SFML/Audio.hpp>
int main()
{
//Creating the window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Game");
window.setKeyRepeatEnabled(false);
//Libraries
#include <SFML/Graphics.hpp>
#include <iostream>
#include <SFML/Audio.hpp>
int main()
{
//Creating the window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Game");
window.setKeyRepeatEnabled(false);
//Libraries
#include <SFML/Graphics.hpp>
#include <iostream>
#include <SFML/Audio.hpp>
int main()
{
//Creating the window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Game");
window.setKeyRepeatEnabled(false);
//Variables
int yVelocityPad1 = 0;
int xVelocityBall = -4;
int yVelocityBall = -4;
int yVelocityPad2 = 0;
////////Shapes
//background
sf::RectangleShape background;
background.setSize(sf::Vector2f(800, 600));
background.setPosition(0, 0);
background.setTexture(&tex_background);
…
AI and Collision
Memasukkan sound
//Libraries
#include <SFML/Graphics.hpp>
#include <iostream>
#include <SFML/Audio.hpp>
int main()
{
//Creating the window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Game");
window.setKeyRepeatEnabled(false);
int main()
{
//Creating the window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Game");
window.setKeyRepeatEnabled(false);
//Libraries
#include <SFML/Graphics.hpp>
#include <iostream>
#include <sstream>
#include <SFML/Audio.hpp>
int main()
{
//Creating the window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Game");
window.setKeyRepeatEnabled(false);
Jalankan program