Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
671d0a9
Started stuff
Dec 17, 2019
cded1e9
Started to link the library to the book
Dec 17, 2019
63be454
Continuing with the linking thing
Dec 24, 2019
c295533
counted pages and books
Dec 31, 2019
1b54094
init, map implemented
Dec 31, 2019
c348359
Update Library.pde
davidlee04 Dec 31, 2019
56d5d38
pull from dev/merge conflicts
Dec 31, 2019
96c6566
recommit didn't save
Dec 31, 2019
2ba83ec
Added a default book; should be done
Dec 31, 2019
d1ee5d5
Continues to change window and library to make it so it opens
Dec 31, 2019
9fbe2cb
Added a default book in library; library shows all books including th…
Jan 7, 2020
ab7f1ed
Merge pull request #6 from LEAGUE-Level7/feature/stats
m990 Jan 7, 2020
047cd7f
Merge pull request #7 from LEAGUE-Level7/feature/addDefaultLibraryBook
m990 Jan 7, 2020
098813c
Pushing so that I can merge into develop
Jan 7, 2020
f08a3d8
Added better images to the default book
Jan 7, 2020
a74748b
Merge pull request #8 from LEAGUE-Level7/feature/improveManualBook
m990 Jan 7, 2020
9245b81
Merge branch 'develop' into feature/LibraryBookLink
Jan 7, 2020
03faed8
Fixing drawing issue
Jan 7, 2020
0096c81
Update Library.pde
davidlee04 Jan 7, 2020
cbef5bf
Library fixed, books drawn/scaling
Jan 14, 2020
0e15a3c
Merge branch 'develop' into feature/SearchingLibrary
davidlee04 Jan 14, 2020
2f24d6f
Merge pull request #9 from LEAGUE-Level7/feature/SearchingLibrary
SquawkyToucan Jan 14, 2020
7b4a0e8
Recommit to fix userguide
Jan 14, 2020
df6d503
Merge pull request #10 from LEAGUE-Level7/feature/SearchingLibrary
EricrPark Jan 21, 2020
c4300c2
Merge branch 'develop' into feature/LibraryBookLink
Jan 21, 2020
8a42ec0
Moved the ExploreWindow in from the other Repo. It works, just waitin…
Jan 21, 2020
99cc028
Merge pull request #11 from LEAGUE-Level7/StoreFeature
BenSinger2005 Jan 21, 2020
d394ab5
Revert "It's the Seljuk Turks"
ankitbisain Jan 21, 2020
7cb886e
Merge pull request #12 from LEAGUE-Level7/revert-11-StoreFeature
EricrPark Jan 21, 2020
54ad48b
got buttons working
Jan 21, 2020
c13f5cf
check if arrow works post merging develop
Jan 28, 2020
466abe4
fixed buttons on the window
Jan 28, 2020
92ef38a
fixed black background
Jan 28, 2020
0f40596
deleted error statements
Jan 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
15 changes: 14 additions & 1 deletion StarterCode/Book.pde
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class Book {
//current page #
private int curPageN;
private PImage coverImg;
private int page;
private int spot;

private Page[] pages;

Expand Down Expand Up @@ -46,5 +48,16 @@ class Book {
public PImage getCoverImg() {
return coverImg;
}

public void setPage(int p){
page = p;
}
public int getPage(){
return page;
}
public void setSpot(int s){
spot = s;
}
public int getSpot(){
return spot;
}
}
169 changes: 143 additions & 26 deletions StarterCode/Library.pde
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
import java.util.TreeMap;
import java.util.Iterator;
import java.util.Map;

class Library {
// is it possible to search? will be determined later but keep it in mind
ArrayList<Book> books;
//ArrayList<Book> books;
//key is title
TreeMap<String, Book> books;

public Library() {
books = new ArrayList<Book>();
books = new TreeMap<String, Book>();

// Add one book, which is an instructions manual, so the program doesn't throw an error when generating the library.
Page[] examplePages = {new Page("Access books in your library.", "click on books.png", color(255, 255, 255)), new Page("Switch pages by using the side arrows.", "use the side arrows.png", color(255, 255, 255)), new Page("Return to the library by clicking exit.", "click exit.png", color(255, 255, 255))};
books.put("User Guide", new Book("User Guide", 3, examplePages, "Centered? User Guide Title.png"));
books.put("User Guide2", new Book("User Guide", 3, examplePages, "Centered? User Guide Title.png"));
books.put("User Guide3", new Book("User Guide", 3, examplePages, "Centered? User Guide Title.png"));
spot = 0;
columns = 2;
currentPage = 0;

buttonColor = color(193, 193, 193);
button2Color = color(194, 194, 194);
Expand All @@ -16,6 +29,7 @@ class Library {

buttonClicked = false;
button2Clicked = false;

}
int spot;
int columns;
Expand All @@ -30,7 +44,7 @@ class Library {
boolean buttonClicked;
boolean button2Clicked;

public Library(ArrayList<Book> books){
public Library(TreeMap<String, Book> books){
this.books = books;
spot = 0;
columns = 2;
Expand All @@ -45,52 +59,50 @@ class Library {
buttonClicked = false;
button2Clicked = false;
}
ArrayList<Book> getBooks(){
TreeMap<String, Book> getBooks(){
return books;
}
void addBook(Book b){
books.add(b);
books.put(b.getTitle(), b);
}
Book getBook(int bookNumber){
return books.get(bookNumber);
Book getBook(String bookName) {
return books.get(bookName);
}
Book getBookWithName(String bookName) {
for (Book b:books) {
if (b.getTitle().equals(bookName)) {
return b;
}
}
return null;
int getCurrentPage(){
return currentPage;
}
//draws the library
void drawLibrary(){
clear();
boolean changed = false;
if(8*spot+8<getBooks().size()) {
if(spot*4+4 < books.size()) {
fill(254, 254, 254);
triangle(0.93*width, 0.45*height, 0.97*width, 0.5*height, 0.93*width, 0.55*height);
if (mousePressed){
color c = get(mouseX, mouseY);
if (c == color(254, 254, 254)){
fill(1, 1, 1);
spot++;
changed = true;
currentPage++;
}
delay(50);
}
triangle(0.93*width, 0.45*height, 0.97*width, 0.5*height, 0.93*width, 0.55*height);
triangle(0.93*width, 0.45*height, 0.97*width, 0.5*height, 0.93*width, 0.55*height);
}
if(spot>0) {
fill(253, 253, 253);
triangle(0.07*width, 0.45*height, 0.03*width, 0.5*height, 0.07*width, 0.55*height);
if (mousePressed){
color c = get(mouseX, mouseY);
if (c == color(253, 253, 253)){
fill(50, 50, 50);
spot+=-1;
spot--;
currentPage--;
changed = true;
}
delay(50);
}
triangle(0.07*width, 0.45*height, 0.03*width, 0.5*height, 0.07*width, 0.55*height);
fill(255, 255, 255);
}

// Your library sign
Expand All @@ -103,17 +115,122 @@ class Library {
// Line across screen at 10% down
line(0, (int)((double)height/(double)10), width, (int)((double)height/(double)10));
// Books
int coverWidth = width*285/500;
int coverHeight = height*285/500;
float xPos = width*428/500;
float yPos = height*428/500;

int newHeight = height - (int)((double)height/(double)10);
int xOffset = (int) ((double) 1/2 * (double) (width - (double) 285/columns - (((double) (2*columns-1)*428)/columns)));
int yOffset = (int)((double)height/10) + (int) ((double) 1/2 * (double) (newHeight - (double) 285/columns - (double) (columns-1)* (double) 428/columns));
for(int i = 0; i < 8 && 8*spot+i < books.size(); i++){
PImage cover = books.get(8*spot+i).getCoverImg();
cover.resize(285/columns, 285/columns);
image(cover, xOffset+(i % (2*columns)) * 428/columns, yOffset+(i - (i % (2*columns)))/(2 * columns) * 428/columns);
float xOffset = (float) width/10;
float yOffset = (float)((double)height/10) + (int) ((double) 1/2 * (double) (newHeight - (double) coverHeight/columns - (double) (columns-1)* (double) yPos/columns));

// Divide treeMap into 2d array so it can be iterated over.
ArrayList<ArrayList<Book>> libraryPages = new ArrayList<ArrayList<Book>>();
ArrayList<Book> temporaryList = new ArrayList<Book>();
int it = 0;
for(Map.Entry<String,Book> entry: books.entrySet()) {
temporaryList.add(entry.getValue());
if (it == 3) {
it = 0;
libraryPages.add(temporaryList);
temporaryList = new ArrayList<Book>();
}
else {
it++;
}

}
if(changed == true){
if(temporaryList.size() > 0) {
libraryPages.add(temporaryList);
}
//drawing books that belong to spot/page
int bookIterator = 0;

for(Book b:libraryPages.get(spot)) {
// iterate over treemap for each book.
PImage cover = b.getCoverImg();
cover.resize(coverWidth/columns, coverHeight/columns);
image(cover, xOffset+(bookIterator % (2)) * xPos/columns, yOffset+(bookIterator - (bookIterator % (2)))/( columns) * yPos/columns);
bookIterator++;
}

if(changed){
background(0,0,0);
drawLibrary();
}
if (mousePressed){
// top left corner button
ArrayList<Book> bookList = new ArrayList<Book>(books.values());
if (mouseX > 78 && mouseX < 214 && mouseY > 99 && mouseY < 241){
inLibrary = false;
println("top left is pressed");
/*if (currentPage == 1){
w.setBook(books.get(0));
w.drawWindow();
}*/
ArrayList<Book> topLeftBooks = new ArrayList<Book>();
for (int i = 0; i < bookList.size(); i++){
if (i % 4 == 0){
topLeftBooks.add(bookList.get(i));
}
}
for (int i = 0; i < topLeftBooks.size(); i++){
println(topLeftBooks.get(i).getTitle());
}
println ("Current page: " + currentPage);
w.setBook(topLeftBooks.get(currentPage));
println ("Book: " + topLeftBooks.get(currentPage).getTitle());
//w.drawWindow();
inWindow=true;
}
if (mouseX > 289 && mouseX < 427 && mouseY > 99 && mouseY < 241){
inLibrary = false;
println("top right is pressed");
ArrayList<Book> topRightBooks = new ArrayList<Book>();
for (int i = 0; i < bookList.size(); i++){
if (i % 4 == 1){
topRightBooks.add(bookList.get(i));
}
}
for (int i = 0; i < topRightBooks.size(); i++){
println(topRightBooks.get(i).getTitle());
}
w.setBook(topRightBooks.get(currentPage));
//w.drawWindow();
inWindow=true;
}
if (mouseX > 78 && mouseX < 214 && mouseY > 314 && mouseY < 453){
inLibrary = false;
println("bottom left is pressed");
ArrayList<Book> topRightBooks = new ArrayList<Book>();
for (int i = 0; i < bookList.size(); i++){
if (i % 4 == 2){
topRightBooks.add(bookList.get(i));
}
}
for (int i = 0; i < topRightBooks.size(); i++){
println(topRightBooks.get(i).getTitle());
}
w.setBook(topRightBooks.get(currentPage));
//w.drawWindow();
inWindow=true;
}
if (mouseX > 289 && mouseX < 427 && mouseY > 314 && mouseY < 453){
inLibrary = false;
println("bottom right is pressed");
ArrayList<Book> topRightBooks = new ArrayList<Book>();
for (int i = 0; i < bookList.size(); i++){
if (i % 4 == 3){
topRightBooks.add(bookList.get(i));
}
}
for (int i = 0; i < topRightBooks.size(); i++){
println(topRightBooks.get(i).getTitle());
}
w.setBook(topRightBooks.get(currentPage));
//w.drawWindow();
inWindow=true;
}
}
}
}
51 changes: 38 additions & 13 deletions StarterCode/StarterCode.pde
Original file line number Diff line number Diff line change
@@ -1,33 +1,58 @@
// Instead of creating a window object with a book, you have a window object and you have a setter that puts in the book later
// Put all visual stuff inside a second method

Library l;
Window w;
Book b1;
int currentPage;
public static boolean inLibrary = true;
public static boolean inWindow = false;
void setup() {
size(500, 500);
String cover1 = "Art Example Two.png";
String cover2 = "Art Example Three.png";

Page[] p = {new Page("Rush is a Canadian band that averages a score of 7.500.", "pixil-frame-0.png", color(255, 255, 255), "rush.wav"), new Page("This score falls behind Taylor Swift by a full tenth.", "img2.png", color(255, 255, 255), "taylor swift.wav")};
Book b1 = new Book("Test", 2, p, cover1);
Book b2 = new Book("Test2", 2, p, cover2);

Page[] p = {new Page("I ran.", "pixil-frame-0.png", color(255, 255, 255)), new Page("I ran2.", "img2.png", color(255, 255, 255))};
Page[] p2 = {new Page("Text", "Art Example One.png", color(0, 0, 0))};
b1 = new Book("Test", 2, p, cover1);
Book b2 = new Book("Test2", 1, p2, cover2);
Book b3 = new Book("Test3", 1, p2, cover2);

w = new Window();

l = new Library();
w = new Window(b1);

currentPage = l.getCurrentPage();

background(0, 0, 0);
for(int i = 0; i<34; i++){
/*for(int i = 0; i<34; i++){
if( (int)Math.sqrt(i)%2 ==0 ){
l.addBook(b1);
}else{
l.addBook(b2);
}
}
}*/

l.addBook(b1);
l.addBook(b2);
l.addBook(b3);


// For now, this is only used to launch the window because it requires a book to be launched.
// This book isn't used otherwise and is not the same as the default book

}

void draw() {
if(w.getStay()) {
w.drawWindow();
} else {
clear();
l.drawLibrary();
}
// 78, 99
// 214, 100
// 81, 241
// 221, 239
//draws the library
if (inLibrary) l.drawLibrary();
// draws the book
//w.draw();
if (inWindow) w.drawWindow();
}

void mousePressed() {
Expand Down
15 changes: 15 additions & 0 deletions StarterCode/StarterCode7272024301000574194.autosave
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Library l = new Library(new ArrayList<Book>());
PImage coverImage;
PImage coverImage2;
void setup() {
background(0, 0, 0);
size(1000, 500);
coverImage = loadImage("Art Example Three.png");
coverImage2 = loadImage("Art Example Two.png");
l.addBook(new Book("La Edad de Oro", new ArrayList<Page>(), coverImage));
l.addBook(new Book("El Presidio Político en Cuba", new ArrayList<Page>(), coverImage2));
}

void draw() {
l.drawLibrary();
}
25 changes: 25 additions & 0 deletions StarterCode/Statistics.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class Statistics {
int numPagesRead;
int numBooksRead;
int timePassed;
public Statistics(){
numPagesRead = 0;
numBooksRead = 0;
timePassed = 0;
}
public int PagesRead(){
return numPagesRead;
}
public int BooksRead(){
return numBooksRead;
}
public int TimePassed(){
return timePassed;
}
public void incrementPages(){
numPagesRead++;
}
public void incrementBooks(){
numBooksRead++;
}
}
Loading