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

Author Topic: Simple 'bouncing ball' example posted on the wiki  (Read 13194 times)

0 Members and 1 Guest are viewing this topic.

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Simple 'bouncing ball' example posted on the wiki
« on: July 10, 2014, 11:19:26 pm »
Hi people

This is just a quick message to let you know that I've posted a simple example program on the wiki. It just bounces a ball randomly around in a window. I wrote it in response to a forum post and would have left it at that, but then it became relevant in another forum thread and I thought I might as well make a wiki entry out of it.

You can find it here: https://github.com/SFML/SFML/wiki/Source%3A-Bouncing-ball

I hope you find it useful.
Comments and criticism is of course welcome.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Simple 'bouncing ball' example posted on the wiki
« Reply #1 on: July 11, 2014, 09:15:47 am »
Just out of curiosity why did you name the "file" bouncing.cc? Never seen anyone use *.cc as file extension...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Simple 'bouncing ball' example posted on the wiki
« Reply #2 on: July 11, 2014, 10:34:18 am »
No special reason except it's one of the extensions that g++ and clang++ by default recognize as C++ - from "man g++":

       file.cc
       file.cp
       file.cxx
       file.cpp
       file.CPP
       file.c++
       file.C
           C++ source code which must be preprocessed.  Note that in .cxx, the
           last two letters must both be literally x.  Likewise, .C refers to
           a literal capital C.
 

For headers I usually use ".h" for C headers and ".hh" for C++ headers, but there are of course other options. Again, from "man g++":

       file.hh
       file.H
       file.hp
       file.hxx
       file.hpp
       file.HPP
       file.h++
       file.tcc
           C++ header file to be turned into a precompiled header.
 

and it's also just what I've always used.
It's also fairly common in my experience; I've had several employers where that was the extension used and if you google for C++ code you'll often run into it.

Just out of curiosity, what do you normally name your C++ files?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Simple 'bouncing ball' example posted on the wiki
« Reply #3 on: July 11, 2014, 10:47:46 am »
I see, well I've never seen a project using *.cc ;D

I use *.cpp and *.hpp. From my experience *.cpp is the most commonly used for C++ files and thus it makes only sense to name the headers the same way.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Simple 'bouncing ball' example posted on the wiki
« Reply #4 on: July 11, 2014, 01:51:22 pm »
Quote
I see, well I've never seen a project using *.cc ;D
Google style guide says to use .h and .cc, and that's what many(?) of their projects use.
Back to C++ gamedev with SFML in May 2023

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Simple 'bouncing ball' example posted on the wiki
« Reply #5 on: July 11, 2014, 02:13:06 pm »
From what I remember, Google's style guide has a few questionable bits. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Simple 'bouncing ball' example posted on the wiki
« Reply #6 on: July 11, 2014, 02:27:58 pm »
But now you know of a few (very successful) projects using .cc. :P
Back to C++ gamedev with SFML in May 2023

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Simple 'bouncing ball' example posted on the wiki
« Reply #7 on: July 13, 2014, 02:56:12 am »
Quote
I see, well I've never seen a project using *.cc ;D
Google style guide says to use .h and .cc, and that's what many(?) of their projects use.
I wouldn't use '.h' for C++ headers. GCC and Clang both treat .h as either C, C++, Objective-C or Objective-C++ by default and that's too much ambiguity and heuristics for me - see my post above for extensions they explicitly treat as C++ (only).
« Last Edit: July 13, 2014, 03:00:05 am by Jesper Juhl »

 

anything