Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 added 4buttonboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
684 changes: 684 additions & 0 deletions Lec01-NSD_Spring2018.ipynb

Large diffs are not rendered by default.

401 changes: 401 additions & 0 deletions Lec02-NSD_Spring2018.ipynb

Large diffs are not rendered by default.

Binary file added bb walk mouthopen state1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bb walk mouthopen state2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bb walk mouthopen state3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bb walk mouthshut state1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bb walk mouthshut state2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bb walk mouthshut state3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added black cuttain with dots on the left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added block 1st floor middle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added block 1st floor right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added block 1st floor with stone middle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added block 1st floor yellow middle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added block 1st floor yellow2 middle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added block 2nd floor left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added block 2nd floor middle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added block 2nd floor right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added block brick 2nd floor middle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added block green rock 2nd floor left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added block green rock 2nd floor middle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added block rock 2nd floor middle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added button.psb
Binary file not shown.
Binary file added decoration candyhouse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added decoration candyhouseonfire.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added decoration circushouse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added decoration flower.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added decoration flower2.png
Binary file added decoration fruithouse.png
Binary file added decoration fruittree.png
Binary file added decoration lamplight.png
Binary file added decoration pavillion.png
Binary file added decoration sakura.png
Binary file added decoration stupid car.png
Binary file added decoration tent.png
Binary file added decoration transfergate.png
Binary file added decoration tree.png
Binary file added decoration willow.png
Binary file added dialog.png
30 changes: 28 additions & 2 deletions game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ void Game::displaymainmeneu()
scene->addItem(titletext);

//create the walking bean
Player *bean= new Player();
bean= new Player();
scene->addItem(bean);

bean->moveautomatically();

//create the buttons
Expand All @@ -57,7 +58,7 @@ void Game::displaymainmeneu()

TextItem *text1= new TextItem(QString("START"),board);
text1->setPos(150/2-text1->boundingRect().width()/2,20);
connect(text1,SIGNAL(clicked()),this,SLOT(vedeo1()));
connect(text1,SIGNAL(clicked()),this,SLOT(conversation1()));


TextItem *text2= new TextItem(QString("LOAD GAMES"),board);
Expand All @@ -78,4 +79,29 @@ void Game::displaymainmeneu()
scene->addItem(board);


}

void Game::conversation1()
{
//qDebug("function conversation1 is deployed");
scene->clear();
QGraphicsPixmapItem *block[32];
for(int i=0;i<32;i++){
block[i]= new QGraphicsPixmapItem();
block[i]->setPixmap(QPixmap(":/pictures/resoureces/pictures/block brick 2nd floor middle.png"));
block[i]->setPos(25*i,570);
scene->addItem(block[i]);
}
bean= new Player();
scene->addItem(bean);
bean->setPixmap(QPixmap::fromImage(bean->walkpix[0]));
bean->setPos(100,570-120);
bean->setFlag(QGraphicsItem::ItemIsFocusable);
bean->setFocus();






}
12 changes: 11 additions & 1 deletion game.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@
#include <QGraphicsView>
#include <QGraphicsScene>
#include "player.h"
#include <QObject>

class Game:public QGraphicsView{
//Q_OBJECT
Q_OBJECT

public:
//public member functions
Game(QWidget *parent=NULL);
void displaymainmeneu();

//public attributes:
Player *bean;

public slots:
void conversation1();


private:
//public attributes
QGraphicsScene *scene;
Expand Down
143 changes: 127 additions & 16 deletions player.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include "player.h"
#include <QTimer>
#include <stdlib.h>
#include <QKeyEvent>
#include <QTime>
#include <QCoreApplication>


Player::Player(QGraphicsItem *parent)
Expand All @@ -20,29 +23,55 @@ Player::Player(QGraphicsItem *parent)

//initialize
walkstate=0;
isjumping=0;
}

void Player::moveright()
{
walkstate++;
walkstate%=3;
/*if(walkstate==0){
walkstate+=(rand()%2)*3;
}*/
setPixmap(QPixmap::fromImage(walkpix[walkstate]));
setPos(x()+5,y());
QTimer *timer1= new QTimer();
QTimer *timer3= new QTimer();
QTimer *timer2= new QTimer();
timer1->setSingleShot(true);
walkstate=1;
connect(timer1,SIGNAL(timeout()),this,SLOT(walkright()));
timer1->start(20);



timer2->setSingleShot(true);
connect(timer2,SIGNAL(timeout()),this,SLOT(walkright()));
timer2->start(40);



timer3->setSingleShot(true);
connect(timer3,SIGNAL(timeout()),this,SLOT(walkright()));
timer3->start(60);




}

void Player::moveleft()
{
walkstate++;
walkstate%=3;
/*if(walkstate==0){
walkstate+=(rand()%2)*3;
}*/
walkstate+=6;
setPixmap(QPixmap::fromImage(walkpix[walkstate]));
setPos(x()-5,y());

QTimer *timer1= new QTimer();
QTimer *timer3= new QTimer();
QTimer *timer2= new QTimer();
timer1->setSingleShot(true);
walkstate=7;
connect(timer1,SIGNAL(timeout()),this,SLOT(walkleft()));
timer1->start(20);

timer2->setSingleShot(true);
connect(timer2,SIGNAL(timeout()),this,SLOT(walkleft()));
timer2->start(40);

timer3->setSingleShot(true);
connect(timer3,SIGNAL(timeout()),this,SLOT(walkleft()));
timer3->start(60);


}

Expand All @@ -54,9 +83,56 @@ void Player::moveautomatically()
direction=1;
QTimer *timer= new QTimer();
connect(timer,SIGNAL(timeout()),this,SLOT(walkauto()));
timer->start(50);
timer->start(70);
}

void Player::jump()
{
isjumping=1;
yspeed=20;
//delete jumptimer;
jumptimer= new QTimer();
connect(jumptimer,SIGNAL(timeout()),this,SLOT(jumpup()));
jumptimer->start(10);
}

void Player::keyPressEvent(QKeyEvent *event)
{

if (event->key()==Qt::Key_Left){
if(pos().x()>0)
moveleft();
}
if (event->key()==Qt::Key_Right){
if (pos().x()<800-100)
moveright();
}
if (event->key()==Qt::Key_Space){
if(isjumping==0){
jump();}
}
/*if (event->key()==Qt::Key_Down){
if(pos().y()<600-100)
setPos(x(),y()+10);
}
if (event->key()==Qt::Key_Space){
bullet *bull=new bullet();
bull->setPos(x()+25,y());
scene()->addItem(bull);
if (bulletsound->state()==QMediaPlayer::PlayingState){
bulletsound->setPosition(0);

}
if (bulletsound->state()==QMediaPlayer::StoppedState){
bulletsound->play();
}


}*/

}


void Player::walkauto()
{
if(direction==1 && x()<=800-138-60){
Expand All @@ -79,3 +155,38 @@ void Player::walkauto()
}

}

void Player::walkright()
{
setPixmap(QPixmap::fromImage(walkpix[walkstate]));
setPos(x()+5+isjumping*10,y());
walkstate++;
walkstate%=3;
}

void Player::walkleft()
{

setPixmap(QPixmap::fromImage(walkpix[walkstate]));
setPos(x()-5-isjumping*10,y());
walkstate++;
walkstate%=3;
walkstate+=6;
}

void Player::jumpup()
{
//qDebug("jumpup function is deployed");

if(y()<=570-120){
setPos(x(),y()-yspeed*0.8);
yspeed-=0.8;
}
else{
setPos(x(),570-120);
disconnect(jumptimer,SIGNAL(timeout()),this,SLOT(jumpup()));
delete jumptimer;
yspeed=0;
isjumping=0;
}
}
21 changes: 18 additions & 3 deletions player.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,37 @@

#include <QGraphicsPixmapItem>
#include <QObject>
#include <QTimer>

class Player:public QObject, public QGraphicsPixmapItem{
Q_OBJECT
public:
//constructor
//constructor
Player(QGraphicsItem *parent=0);
//public member function
//public member function
//walk and jump
void moveright();
void moveleft();
void setwalkstate(int w){walkstate=w;}
void moveautomatically();

void jump();

void keyPressEvent(QKeyEvent *event);

//public attributes
QImage walkpix[12];
public slots:
void walkauto();
void walkright();
void walkleft();
void jumpup();
private:
int direction;
QImage walkpix[12];
int walkstate;
float yspeed;
int isjumping;
QTimer *jumptimer;

};
#endif // PLAYER_H
2 changes: 2 additions & 0 deletions res.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@
<file>resoureces/pictures/decoration circushouse.png</file>
<file>resoureces/pictures/decoration fruithouse.png</file>
<file>resoureces/pictures/decoration pavillion.png</file>
<file>resoureces/pictures/black cuttain with dots on the left.png</file>
<file>resoureces/pictures/block brick 2nd floor middle.png</file>
</qresource>
</RCC>
Binary file added scheme left.png
Binary file added scheme middle.png
Binary file added stair middlepart.png
Binary file added stair upperend.png
2 changes: 1 addition & 1 deletion theadventureoftheblackbean.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.1.0, 2017-01-11T12:34:27. -->
<!-- Written by QtCreator 4.1.0, 2017-01-12T21:59:04. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down