Class Six openFrameworks! A software frameworks, by which we mean: - - PowerPoint PPT Presentation

class six
SMART_READER_LITE
LIVE PREVIEW

Class Six openFrameworks! A software frameworks, by which we mean: - - PowerPoint PPT Presentation

The Code Liberation Foundation Lecture 5 Structs, classes, the heap and the stack Class Six openFrameworks! A software frameworks, by which we mean: a software infrastructure that provides low-level functionality Will allow you to


slide-1
SLIDE 1

The Code Liberation Foundation

Lecture 5 Structs, classes, the heap and the stack

Class Six

  • penFrameworks!
  • A software frameworks, by which we mean: a software infrastructure that provides low-level

functionality

  • Will allow you to start playing with assets (images, sounds) as well as interactivity (mouse

movement, keyboard interaction) Download it from openframeworks.cc. And check out the reference!

slide-2
SLIDE 2

The Code Liberation Foundation

  • penFrameworks
  • Making a new project: navigate to the emptyExample folder and copy it
  • Make a folder within the app folder (not required, but helps keep things neat
  • Paste emptyExample into to your projects folder
  • Your project folder has to be exactly three levels down from the base oF folder!
slide-3
SLIDE 3

The Code Liberation Foundation

  • penFrameworks
  • main.cpp: largely handles launching the app; no longer our main place to work in
  • testApp.h: where you declare global variables and function prototypes
  • testApp.cpp: your new main!

A basic oF app starts with three fjles in src: main.cpp, testApp.h, and testApp.cpp.

slide-4
SLIDE 4

The Code Liberation Foundation

  • penFrameworks
  • penFrameworks runs on a frame system. There are typically 60 frames per second.

There are three main functions/loops in openFrameworks.

  • void testApp::setup() runs exactly once, right when the program starts. Useful to give

starting values to variables, e.g. start the player’s health at 100.

  • void testApp::update() runs once per frame. This is where you should put your number

crunching, e.g. if the player is poisoned, their health should go down by 1 per frame.

  • void testApp::draw() also runs once per frame, after update loop. This is where you should

put visual stufg, e.g. drawing the health value.

RUN SETUP UPDATE DRAW

slide-5
SLIDE 5

The Code Liberation Foundation

  • penFrameworks

In openFrameworks, x-values get bigger to the right, and y-values get bigger going down.

X=0 x=WIDTH y=0 y=HEIGHT

slide-6
SLIDE 6

The Code Liberation Foundation

  • penFrameworks

In openFrameworks, x-values get bigger to the right, and y-values get bigger going down.

X=0 x=WIDTH y=0 y=HEIGHT (3,2)

slide-7
SLIDE 7

The Code Liberation Foundation

  • penFrameworks
  • fEllipse(x, y, width, height);
  • fRect(x, y, width, height);
  • fLine(x1, y1, x2, y2);
slide-8
SLIDE 8

The Code Liberation Foundation

  • penFrameworks
slide-9
SLIDE 9

The Code Liberation Foundation

  • penFrameworks
slide-10
SLIDE 10

The Code Liberation Foundation

  • penFrameworks
  • fGetWidth()
  • fGetHeight()

mouseX mouseY

slide-11
SLIDE 11

The Code Liberation Foundation

  • penFrameworks
  • fSetColor(int r, int g, int b)
  • fEnableAlphaBlending()
  • fSetColor(int r, int g, int b, int a)
  • fFill()
  • fDisableAlphaBlending()

setsclr setsclr italpa netsapesillaeill

  • fNoFill()

netsapesntaeill enablestransparency disablestransparency