Skip to content

Commit f86f87b

Browse files
authored
Merge pull request #298 from roymacdonald/fix-projectStructure_remove_codeblocks
Updated setup and project structure chapter:
2 parents 01acfcc + 8fa5cb8 commit f86f87b

File tree

6 files changed

+129
-57
lines changed

6 files changed

+129
-57
lines changed

Diff for: chapters/OOPs!/chapter.md

+10-8
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ Every class has two files: a header file, also known as declarations file with t
2626
A very easy way of knowing what these two files do is to think of the header file (.h) as a recipe, a list of the main ingredients of your cookie. The implementation file (.cpp) is what we're going to do with them, how you mix and work them to be the perfect cookie!
2727
So let's see how it works:
2828

29-
First of all, let's create the two class files:
30-
If you're using Xcode as your IDE (it stands for Integrated Development Environment), select the src folder and left Click (or CTRL + click), on the pop-up menu select 'New File' and you'll be taken to a new window menu, choose the appropriate platform you're developing for (OS X or iOS) and select C++ class and finally choose a name (we used 'Ball'). You'll automatically see the two files in your 'src' folder: 'Ball.h' and 'Ball.cpp'.
31-
If you are using Code::Blocks create a new project from empty one given inside the "examples" directory (or check out the ProjectGenerator). Copy the folder "empty" and rename it to "OOP". Change into this new directory, copy the "emptyExample" and rename it to "ball1". Inside the "ball1" directory rename "emptyExample.workspace" to "ball1.workspace" and "emptyExample.cbp" to "ball1.cbp". Now you have a dedicated directory and a dedicated project to play around with. Open "ball1.cbp" with Code:: Blocks, right-click on the "emptyExample" workspace, select "Properties" (last entry in the list) and change the title of the project. The "src" directory in your project contains all the files you need to edit in this chapter. Add two new files inside the 'src' directory by either using 'File'->'New'->'Empty File' or pressing Tab+Ctrl+N. One file should be named 'Ball.h' and the other 'Ball.cpp'.
32-
Now let's edit your class header (.h) file. Feel free to delete all its contents and let's start from scratch:
33-
Declare a class in the header file (.h). In this case, the file name should be Ball.h.
34-
Follow the code below and type into your own Ball.h file, please note the comments I've included to guide you along.
29+
First of all, let's create the two class files: `Ball.h` and `Ball.cpp` and place these in the project's `src` folder.
30+
31+
If you're using Xcode as your IDE (it stands for Integrated Development Environment), select the src folder and left Click (or CTRL + click), on the pop-up menu select 'New File' and you'll be taken to a new window menu, choose the appropriate platform you're developing for (OS X or iOS) and select C++ class and finally choose a name (we used 'Ball'). You'll automatically see the two files in your `src` folder: `Ball.h` and `Ball.cpp`.
32+
33+
If you are using other IDEs it should be quite similar.
34+
35+
Declare a class in the header file (.h). In this case, the file name should be `Ball.h`.
36+
Follow the code below and type into your own `Ball.h` file, please note the comments I've included to guide you along.
3537

3638
```cpp
3739
#ifndef _BALL // if this class hasn't been defined, the program can define it
@@ -66,7 +68,7 @@ The 'if statement' (#ifndef) is a way to prevent the repetition of header files
6668

6769
We will now create a class for a ball object. This ball will have color, speed and direction properties: it will move across the screen and bounce against the wall. Some of these properties we will create with randomized attributes but we'll be careful to create the right logic for its motion behaviors.
6870

69-
Here's how you can write the class Ball.cpp file, the implementation file:
71+
Here's how you can write the class `Ball.cpp` file, the implementation file:
7072

7173
```cpp
7274
#include "Ball.h"
@@ -275,7 +277,7 @@ void Ball::setup(float _x, float _y, int _dim){
275277
}
276278
```
277279

278-
Your Ball.cpp file should look like this by now:
280+
Your `Ball.cpp` file should look like this by now:
279281

280282
```cpp
281283
#include "Ball.h"

Diff for: chapters/intro_to_graphics/chapter.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Graphics
55

66
This chapter builds off of the *C++ Basics* and *Setup and Project Structure* chapters, so if you aren't familiar with basic C++ and creating openFrameworks projects, check out those chapters first.
77

8-
In sections 1 and 2, we will create "paintbrushes" where the mouse is our brush and our code defines how our brush makes marks on the screen. In section 3, we will explore something called "coordinate system transformations" to create hypnotizing, spiraling rectangles. Source code for the projects is linked at the end of each section. If you feel lost at any point, don't hesitate to look at the completed code! You can check out the whole collection of code [here](https://github.com/openframeworks/ofBook/tree/master/chapters/intro_to_graphics/code) - both for standard development structure (Xcode, Code::Blocks, etc.) and for ofSketch.
8+
In sections 1 and 2, we will create "paintbrushes" where the mouse is our brush and our code defines how our brush makes marks on the screen. In section 3, we will explore something called "coordinate system transformations" to create hypnotizing, spiraling rectangles. Source code for the projects is linked at the end of each section. If you feel lost at any point, don't hesitate to look at the completed code! You can check out the whole collection of code [here](https://github.com/openframeworks/ofBook/tree/master/chapters/intro_to_graphics/code) - both for standard development structure (Xcode, QtCreator, Visual Studio, etc.) and for ofSketch.
99

1010
If you are following along using ofSketch, great! There are a couple things to note. Coding in ofSketch is a bit different than coding in other Xcode, Code::Blocks, etc. 1) There will be a few points where variables are added to something called a header file (`.h`). When you see those instructions, that means you should put your variables above your `setup()` function in ofSketch. 2) You'll want to use `ofSetWindowShape(int width, int height)` in `setup()` to control the size of your application. 3) Some of the applications you write will save images to your computer. You can find them in your ofSketch folder, by looking for `ofSketch/data/Projects/YOUR_PROJECT_NAME/bin/data/`.
1111

Diff for: chapters/ofSketch/chapter.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ One of the main goals in developing ofSketch is to decrease the barriers to entr
2020

2121
### What is ofSketch NOT Good For?
2222

23-
- Replacing a professional IDE like Xcode, Code::Blocks, Visual Studio, etc...
23+
- Replacing a professional IDE like Xcode, QtCreator, Visual Studio, etc...
2424
- Building sizable projects or applications
2525

2626
### How does ofSketch work?

0 commit comments

Comments
 (0)