2021互動技術
2022年1月17日 星期一
Noteeee [Final] Week19
WEE13
東西都差不多了
PImage img,monster,hero,pic1,button;
int N=0;
int condition;
float heroX = 100,heroY = 400;
float monsterX = 150,monsterY = 10;
float []arrowX = new float[100];
float []arrowY = new float[100];
float []arrowVX = new float[100];
float []arrowVY = new float[100];
boolean []arrowFlying = new boolean[100];
boolean gamestart = false;
boolean gameover = false;
void setup(){
size(300,500);
img = loadImage("background.jpg");
monster = loadImage("mon.jpg");
hero = loadImage("bow.jpg");
pic1 = loadImage("pic1.jpg");
button = loadImage("button.jpg");
}
void draw(){
background(255);
image(img,0,0);
image(monster,80,10);
image(hero,heroX,heroY);
if(keyPressed ){
if(keyCode == LEFT){
heroX -= 5;
}
if(keyCode == RIGHT){
heroX += 5;
}
}
for(int i=0;i<N;i++){
arrowY[i] += arrowVY[i];
ellipse(arrowX[i],arrowY[i],10,10);
}
}
void mouseClicked(){
N++;
arrowX[N-1] = heroX;
arrowY[N-1] = heroY;
arrowVX[N-1] = 0;
arrowVY[N-1] = -3;
}
void mousePressed(){
gamestart = true;
if(condition==0){
image(pic1,0,150);
image(button,100,200);
}
if(mouseButton == LEFT&&dist(300,360,mouseX,mouseY)<60){
condition = 1;
}
}
WEEK12
期末作業
這勿再加上弓箭、按鈕
PImage img,monster,hero,pic1,button;
int N=0;
int condition;
float heroX = 100,heroY = 400;
float monsterX = 150,monsterY = 10;
float []arrowX = new float[100];
float []arrowY = new float[100];
float []arrowVX = new float[100];
float []arrowVY = new float[100];
boolean []arrowFlying = new boolean[100];
boolean gamestart = false;
boolean gameover = false;
void setup(){
size(300,500);
img = loadImage("background.jpg");
monster = loadImage("mon.jpg");
hero = loadImage("bow.jpg");
pic1 = loadImage("pic1.jpg");
button = loadImage("button.jpg");
}
void draw(){
background(255);
image(img,0,0);
image(monster,80,10);
image(hero,heroX,heroY);
if(keyPressed ){
if(keyCode == LEFT){
heroX -= 5;
}
if(keyCode == RIGHT){
heroX += 5;
}
}
for(int i=0;i<N;i++){
arrowY[i] += arrowVY[i];
ellipse(arrowX[i],arrowY[i],10,10);
}
}
void mouseClicked(){
N++;
arrowX[N-1] = heroX;
arrowY[N-1] = heroY;
arrowVX[N-1] = 0;
arrowVY[N-1] = -3;
}
void mousePressed(){
gamestart = true;
if(condition==0){
image(pic1,0,150);
image(button,100,200);
}
if(mouseButton == LEFT&&dist(300,360,mouseX,mouseY)<60){
condition = 1;
}
}
弓箭
按鈕
WEEK11
還是做期末作業
這次加上圖片
PImage img,monster,hero,pic1,button;
int N=0;
int condition;
float heroX = 100,heroY = 400;
float monsterX = 150,monsterY = 10;
float []arrowX = new float[100];
float []arrowY = new float[100];
float []arrowVX = new float[100];
float []arrowVY = new float[100];
boolean []arrowFlying = new boolean[100];
boolean gamestart = false;
boolean gameover = false;
void setup(){
size(300,500);
img = loadImage("background.jpg");
monster = loadImage("mon.jpg");
hero = loadImage("bow.jpg");
pic1 = loadImage("pic1.jpg");
button = loadImage("button.jpg");
}
void draw(){
background(255);
image(img,0,0);
image(monster,80,10);
image(hero,heroX,heroY);
if(keyPressed ){
if(keyCode == LEFT){
heroX -= 5;
}
if(keyCode == RIGHT){
heroX += 5;
}
}
for(int i=0;i<N;i++){
arrowY[i] += arrowVY[i];
ellipse(arrowX[i],arrowY[i],10,10);
}
}
void mouseClicked(){
N++;
arrowX[N-1] = heroX;
arrowY[N-1] = heroY;
arrowVX[N-1] = 0;
arrowVY[N-1] = -3;
}
void mousePressed(){
gamestart = true;
if(condition==0){
image(pic1,0,150);
image(button,100,200);
}
if(mouseButton == LEFT&&dist(300,360,mouseX,mouseY)<60){
condition = 1;
}
}
背景
期末作業完成week14
期末作業完成:
Youtube連結:電流急急棒 - YouTube
程式碼:
PImage ball,maze,gem;
int[] rangeX = {0,125};
int[] rangeY = {480,235};
int ballposX = 30,ballposY = 215;
int offsetX = 0,offsetY = 0;
boolean is_over = false;
boolean is_win = false;
void setup()
{
size(640,480);
maze=loadImage("maze.png");
ball=loadImage("ball.png");
gem=loadImage("gem.png");
}
void draw()
{
background(255);
imageMode(CENTER);
image(maze,320,240);
image(gem,590,415);
image(ball,ballposX,ballposY);
if(is_over && !is_win)
{
GameOver();
}
if(is_win)
{
Win();
}
}
void mousePressed()
{
offsetX = ballposX - mouseX;
offsetY = ballposY - mouseY;
}
void mouseDragged()
{
if(!is_over)
{
ballposX = offsetX + mouseX;
ballposY = offsetY + mouseY;
}
detCollision();
}
void GameOver()
{
textAlign(CENTER);
textSize(100);
fill(0);
text("Game Over",320,240);
}
void Win()
{
textAlign(CENTER);
textSize(100);
fill(0);
text("Victory",320,240);
}
void detCollision()
{
//左下
if(ballposX-13 > 0 && ballposX-13 < 125 && ballposY+13 > 235)
{
is_over = true;
}
if(ballposX-13 > 0 && ballposX-13 < 125 && ballposY-13 > 235)
{
is_over = true;
}
if(ballposX+13 > 0 && ballposX+13 < 125 && ballposY+13 > 235)
{
is_over = true;
}
if(ballposX+13 > 0 && ballposX+13 < 125 && ballposY-13 > 235)
{
is_over = true;
}
//左上
if(ballposX-13 > 0 && ballposX-13 < 125 && ballposY+13 < 195)
{
is_over = true;
}
if(ballposX-13 > 0 && ballposX-13 < 125 && ballposY-13 < 195)
{
is_over = true;
}
if(ballposX+13 > 0 && ballposX+13 < 125 && ballposY+13 < 195)
{
is_over = true;
}
if(ballposX+13 > 0 && ballposX+13 < 125 && ballposY-13 < 195)
{
is_over = true;
}
//右上
if(ballposX+13 > 515 && ballposX+13 < 640 && ballposY-13 < 395)
{
is_over = true;
}
if(ballposX+13 > 515 && ballposX+13 < 640 && ballposY+13 < 395)
{
is_over = true;
}
if(ballposX+13 > 515 && ballposX+13 < 640 && ballposY-13 < 395)
{
is_over = true;
}
if(ballposX-13 > 515 && ballposX-13 < 640 && ballposY-13 < 395)
{
is_over = true;
}
//中上
if(ballposX+13 > 125 && ballposX+13 < 515 && ballposY-13 < 45)
{
is_over = true;
}
if(ballposX-13 > 125 && ballposX-13 < 515 && ballposY-13 < 45)
{
is_over = true;
}
//中下
if(ballposX+13 > 125 && ballposX+13 < 640 && ballposY+13 > 435)
{
is_over = true;
}
if(ballposX-13 > 125 && ballposX-13 < 640 && ballposY-13 > 435)
{
is_over = true;
}
//左下2
if(ballposX+13 > 125 && ballposX+13 < 275 && ballposY+13 > 285)
{
is_over = true;
}
if(ballposX-13 > 125 && ballposX-13 < 275 && ballposY+13 > 285)
{
is_over = true;
}
if(ballposX-13 > 125 && ballposX-13 < 275 && ballposY-13 > 285)
{
is_over = true;
}
//右下2
if(ballposX+13 > 275 && ballposX+13 < 475 && ballposY+13 > 385)
{
is_over = true;
}
if(ballposX-13 > 275 && ballposX-13 < 475 && ballposY+13 > 385)
{
is_over = true;
}
if(ballposX-13 > 275 && ballposX-13 < 475 && ballposY-13 > 385)
{
is_over = true;
}
//右下2上面的
if(ballposX+13 > 416 && ballposX+13 < 475 && ballposY-13 > 235)
{
is_over = true;
}
if(ballposX+13 > 416 && ballposX+13 < 475 && ballposY+13 > 235)
{
is_over = true;
}
if(ballposX-13 > 416 && ballposX-13 < 475 && ballposY+13 > 235)
{
is_over = true;
}
//中間
if(ballposX+13 > 165 && ballposX+13 < 376 && ballposY-13 > 85 && ballposY-13 < 245)
{
is_over = true;
}
if(ballposX+13 > 165 && ballposX+13 < 376 && ballposY+13 > 85 && ballposY+13 < 245)
{
is_over = true;
}
if(ballposX-13 > 165 && ballposX-13 < 376 && ballposY+13 > 85 && ballposY+13 < 245)
{
is_over = true;
}
if(ballposX-13 > 165 && ballposX-13 < 376 && ballposY+13 > 85 && ballposY-13 < 245)
{
is_over = true;
}
//中間右
if(ballposX+13 > 376 && ballposX+13 < 475 && ballposY-13 > 85 && ballposY-13 < 195)
{
is_over = true;
}
if(ballposX+13 > 376 && ballposX+13 < 475 && ballposY+13 > 85 && ballposY+13 < 195)
{
is_over = true;
}
if(ballposX-13 > 376 && ballposX-13 < 475 && ballposY+13 > 85 && ballposY+13 < 195)
{
is_over = true;
}
if(ballposX-13 > 376 && ballposX-13 < 475 && ballposY+13 > 85 && ballposY-13 < 195)
{
is_over = true;
}
//中間右下
if(ballposX+13 > 315 && ballposX+13 < 376 && ballposY-13 > 245 && ballposY-13 < 345)
{
is_over = true;
}
if(ballposX+13 > 315 && ballposX+13 < 376 && ballposY+13 > 245 && ballposY+13 < 345)
{
is_over = true;
}
if(ballposX-13 > 315 && ballposX-13 < 376 && ballposY+13 > 245 && ballposY+13 < 345)
{
is_over = true;
}
if(ballposX-13 > 315 && ballposX-13 < 376 && ballposY+13 > 245 && ballposY-13 < 345)
{
is_over = true;
}
//寶石
if(ballposX > 579 && ballposX < 601 && ballposY > 409 && ballposY < 421)
{
is_win = true;
is_over = true;
}
if(ballposX > 579 && ballposX < 601 && ballposY > 409 && ballposY < 421)
{
is_win = true;
is_over = true;
}
if(ballposX > 579 && ballposX < 601 && ballposY > 409 && ballposY < 421)
{
is_win = true;
is_over = true;
}
if(ballposX > 579 && ballposX < 601 && ballposY > 409 && ballposY < 421)
{
is_win = true;
is_over = true;
}
}
WEEK10
開始做期末作品
PImage img,monster,hero,pic1,button;
int N=0;
int condition;
float heroX = 100,heroY = 400;
float monsterX = 150,monsterY = 10;
float []arrowX = new float[100];
float []arrowY = new float[100];
float []arrowVX = new float[100];
float []arrowVY = new float[100];
boolean []arrowFlying = new boolean[100];
boolean gamestart = false;
boolean gameover = false;
void setup(){
size(300,500);
img = loadImage("background.jpg");
monster = loadImage("mon.jpg");
hero = loadImage("bow.jpg");
pic1 = loadImage("pic1.jpg");
button = loadImage("button.jpg");
}
void draw(){
background(255);
image(img,0,0);
image(monster,80,10);
image(hero,heroX,heroY);
if(keyPressed ){
if(keyCode == LEFT){
heroX -= 5;
}
if(keyCode == RIGHT){
heroX += 5;
}
}
for(int i=0;i<N;i++){
arrowY[i] += arrowVY[i];
ellipse(arrowX[i],arrowY[i],10,10);
}
}
void mouseClicked(){
N++;
arrowX[N-1] = heroX;
arrowY[N-1] = heroY;
arrowVX[N-1] = 0;
arrowVY[N-1] = -3;
}
void mousePressed(){
gamestart = true;
if(condition==0){
image(pic1,0,150);
image(button,100,200);
}
if(mouseButton == LEFT&&dist(300,360,mouseX,mouseY)<60){
condition = 1;
}
}
WEEK6
學習text
size(500,500);
fill(#1777A2);
textSize(50);
text("HIIII!",50,50);
再來是不同程式碼,座標不同
void setup()
{
size(500,500);
fill(#1777A2);
textSize(50);
}
void draw()
{
text("HIIII!",50,100);
}
使用frameCount來跑秒,一秒60偵
void setup()
{
size(500,500);
fill(#1777A2);
textSize(50);
}
void draw()
{
background(255);
text("Time:"+frameCount,50,100);
}
再來是按下滑鼠後,會變換文字