• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Code_Black

C++ help

13 posts in this topic


Hi guys. I really want to learn how to create games. I have a basic understanding of C++ and have tried to find good high quality tutorials online but there are so many it's difficult to break through the noise as well as they all have different programming styles. If anyone knows of good paid or free tutorials. It would be greatly appreciated. Thank you
0

Share this post


Link to post
Share on other sites

Hi @Code_Black,

There are a lot of game engines, each of them with determined supported languages. As you say you have a basic undertand of C++, I can recommended you Cocos2d-x (http://www.cocos2d-x.org/). If you like, there are books and many resources to learn it. I will only put two sites:
 
 
I hope this is helpfull for you,
 
Regards
0

Share this post


Link to post
Share on other sites

If you want some fun / more code based working for 3D stuff using DirectX a fair good book in my opinion is "Introduction to 3D Game Programming with DirectX 12" by Frank Luna. Back when I was in uni I read / worked through the DX9 version, Also do own the DX12 version but havnt had time to read though.

Good for like an intro to how direct x works and getting some basic stuff running without like the use of pre-built game engines etc

0

Share this post


Link to post
Share on other sites

I highly recommend the Handmade Hero series (https://hero.handmade.network/episodes). You'll learn a lot about the underlying stuff that the engines, you may use, do. There is a lot of material and he explains it in depth and from someone who has made game professionally. 

0

Share this post


Link to post
Share on other sites
Yes I'm trying to fucus on C++/sfml. So anything on those subjects wolud be great.
1

Share this post


Link to post
Share on other sites
Yes I was hoping someone could help me with some generic code. So I have a player with a x,y location and I'm trying to figure out how to rotate the weapon around the player so it's always on one side. Thanks
0

Share this post


Link to post
Share on other sites
I strongly recommend to have a look at the tutorial series "sparky game engine" from Cherno, on YouTube. It focuses more on creating a basic engine than creating a game itself. He also gives a good introduction to c++.

You can also give a look to "thin matrix", on you tube. He codes in Java though.
0

Share this post


Link to post
Share on other sites

Posted (edited)

Hi, for a 2D game, you can use sinf & cosf, multiply that by the distance, add this to your player coordinates,

now you have your rotated gun position,

 

You should learn about matrices, a matrix contains position and rotation, in DX9 there are functions to change & rotate stuff.

Edited by the incredible smoker
0

Share this post


Link to post
Share on other sites
Yes thank you do you think you could take at my code and help me with that?
#include <iostream>
#include <SFML/Graphics.hpp>
#include<cmath>
//#include"block.h"
//sf::RenderWindow win(sf::VideoMode(800,600),"RPG");
using namespace std;
enum class State{PAUSE,PLAYING};

class Block{
sf::Texture tex;
sf::Sprite spr;
sf::Vector2f pos;

public:
int pos_i;
Block(float x=0.f,float y=0.f,float hi=0.f,float wd=0.f){

sf::Vector2f size(hi,wd);
tex.loadFromFile("1.png");
pos.x=x; pos.y=y;
spr.setTexture(tex);
spr.setTextureRect(sf::IntRect(0,0,size.x,size.y));
spr.setPosition(sf::Vector2f(x,y));
}


void draw(sf::RenderWindow* win){

win->draw(spr);
}


void set_size(sf::Vector2f size){spr.setTextureRect(sf::IntRect(0,0,size.x,size.y));}
sf::Vector2f get_pos(){return pos;}
sf::Sprite& get_tex(){return spr;}

void set_pos(sf::Vector2f pos){spr.move(pos);}
};

class weapon{
Block blc;
bool m_up;
bool m_dn;
bool m_lt;
bool m_rt;
sf::Vector2f m_res;

public:
weapon():blc(0,0,8,8){}
void move_rt(){m_rt=true;}
void move_lt(){m_lt=true;}
void move_up(){m_up=true;}
void move_dn(){m_dn=true;}

void stop_rt(){m_rt=false;}
void stop_lt(){m_lt=false;}
void stop_up(){m_up=false;}
void stop_dn(){m_dn=false;}
void setPos(sf::Vector2f pos){blc.set_pos(pos);}
sf::Sprite getWep(){return blc.get_tex();}
void update( sf::Vector2f pos ,sf::Vector2i mse_pos){

if(m_up)
blc.set_pos(pos - sf::Vector2f(0.f,10.f));
if(m_dn)
blc.set_pos(pos + sf::Vector2f(0.f,10.f));
if(m_rt)
blc.set_pos(pos - sf::Vector2f(10.f,0.f));
if(m_lt)
blc.set_pos(pos + sf::Vector2f(10.f,0.f));



float angle=(atan2(mse_pos.y-m_res.y/2,mse_pos.x-m_res.x/2))*180/3.14f;

blc.get_tex().setRotation(angle);
}



};

class Player{
Block blc;
weapon Weapon;
sf::Vector2f m_res;


bool m_up;
bool m_dn;
bool m_lt;
bool m_rt;

float m_speed;
sf::Time last_hit;

public:
Player():blc(0,0,16,16){

}

void spawn(sf::Vector2f res,sf::Vector2f loc){
blc.set_pos(loc);
Weapon.setPos(sf::Vector2f(loc.x+5.0f,loc.y+5.0));


m_res.x=res.x;
m_res.y=res.y;

}
weapon& getWep(){return Weapon;}
bool hit(sf::Time time_hit);
sf::FloatRect get_pos(){return blc.get_tex().getGlobalBounds();}
sf::Vector2f get_cen(){return blc.get_pos();}
float get_rot(){return blc.get_tex().getRotation();}
sf::Sprite get_pla(){return blc.get_tex();}

void move_rt(){m_rt=true;}
void move_lt(){m_lt=true;}
void move_up(){m_up=true;}
void move_dn(){m_dn=true;}

void stop_rt(){m_rt=false;}
void stop_lt(){m_lt=false;}
void stop_up(){m_up=false;}
void stop_dn(){m_dn=false;}

void update( sf::Vector2f pos ,sf::Vector2i mse_pos){

if(m_up)

blc.set_pos(pos - sf::Vector2f(0.f,10.f));
if(m_dn)
blc.set_pos(pos + sf::Vector2f(0.f,10.f));
if(m_rt)
blc.set_pos(pos - sf::Vector2f(10.f,0.f));

if(m_lt)
blc.set_pos(pos + sf::Vector2f(10.f,0.f));



float angle=(atan2(mse_pos.y-m_res.y/2,mse_pos.x-m_res.x/2))*180/3.14f;

blc.get_tex().setRotation(angle);
}


};
0

Share this post


Link to post
Share on other sites

Please use the code tags when posting code.

In the editor it's the button that looks like <>.

0

Share this post


Link to post
Share on other sites
Yes this is my first time. I'm new to this whole thing so thanks for all the feedback.

Yes thank you do you think you could take at my code and help me with that?
#include <iostream>
#include <SFML/Graphics.hpp>
#include<cmath>
//#include"block.h"
//sf::RenderWindow win(sf::VideoMode(800,600),"RPG");
using namespace std;
enum class State{PAUSE,PLAYING};
class Block{
sf::Texture tex;
sf::Sprite spr;
sf::Vector2f pos;
public:
int pos_i;
Block(float x=0.f,float y=0.f,float hi=0.f,float wd=0.f){
sf::Vector2f size(hi,wd);
tex.loadFromFile("1.png");
pos.x=x; pos.y=y;
spr.setTexture(tex);
spr.setTextureRect(sf::IntRect(0,0,size.x,size.y));
spr.setPosition(sf::Vector2f(x,y));
}
void draw(sf::RenderWindow* win){
win->draw(spr);
}
void set_size(sf::Vector2f size){spr.setTextureRect(sf::IntRect(0,0,size.x,size.y));}
sf::Vector2f get_pos(){return pos;}
sf::Sprite& get_tex(){return spr;}
void set_pos(sf::Vector2f pos){spr.move(pos);}
};
class weapon{
Block blc;
bool m_up;
bool m_dn;
bool m_lt;
bool m_rt;
sf::Vector2f m_res;
public:
weapon():blc(0,0,8,8){}
void move_rt(){m_rt=true;}
void move_lt(){m_lt=true;}
void move_up(){m_up=true;}
void move_dn(){m_dn=true;}
void stop_rt(){m_rt=false;}
void stop_lt(){m_lt=false;}
void stop_up(){m_up=false;}
void stop_dn(){m_dn=false;}
void setPos(sf::Vector2f pos){blc.set_pos(pos);}
sf::Sprite getWep(){return blc.get_tex();}
void update( sf::Vector2f pos ,sf::Vector2i mse_pos){
if(m_up)
blc.set_pos(pos - sf::Vector2f(0.f,10.f));
if(m_dn)
blc.set_pos(pos + sf::Vector2f(0.f,10.f));
if(m_rt)
blc.set_pos(pos - sf::Vector2f(10.f,0.f));
if(m_lt)
blc.set_pos(pos + sf::Vector2f(10.f,0.f));
float angle=(atan2(mse_pos.y-m_res.y/2,mse_pos.x-m_res.x/2))*180/3.14f;
blc.get_tex().setRotation(angle);
}
};
class Player{
Block blc;
weapon Weapon;
sf::Vector2f m_res;
bool m_up;
bool m_dn;
bool m_lt;
bool m_rt;
float m_speed;
sf::Time last_hit;
public:
Player():blc(0,0,16,16){
}
void spawn(sf::Vector2f res,sf::Vector2f loc){
blc.set_pos(loc);
Weapon.setPos(sf::Vector2f(loc.x+5.0f,loc.y+5.0));
m_res.x=res.x;
m_res.y=res.y;
}
weapon& getWep(){return Weapon;}
bool hit(sf::Time time_hit);
sf::FloatRect get_pos(){return blc.get_tex().getGlobalBounds();}
sf::Vector2f get_cen(){return blc.get_pos();}
float get_rot(){return blc.get_tex().getRotation();}
sf::Sprite get_pla(){return blc.get_tex();}
void move_rt(){m_rt=true;}
void move_lt(){m_lt=true;}
void move_up(){m_up=true;}
void move_dn(){m_dn=true;}
void stop_rt(){m_rt=false;}
void stop_lt(){m_lt=false;}
void stop_up(){m_up=false;}
void stop_dn(){m_dn=false;}
void update( sf::Vector2f pos ,sf::Vector2i mse_pos){
if(m_up)
blc.set_pos(pos - sf::Vector2f(0.f,10.f));
if(m_dn)
blc.set_pos(pos + sf::Vector2f(0.f,10.f));
if(m_rt)
blc.set_pos(pos - sf::Vector2f(10.f,0.f));
if(m_lt)
blc.set_pos(pos + sf::Vector2f(10.f,0.f));
float angle=(atan2(mse_pos.y-m_res.y/2,mse_pos.x-m_res.x/2))*180/3.14f;
blc.get_tex().setRotation(angle);
}
};

yes I forgot player/weapon update in main

sf::Vector2f plaPos(pla.get_cen());
pla.update(plaPos,sf::Mouse::getPosition());
pla.getWep().update(plaPos,sf::Mouse::getPosition());
}
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0