Skip to content

haha lodička pew #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>18</version>
<version>19</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
Expand All @@ -33,7 +33,7 @@
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
<version>4.0.5</version>
<version>4.0.6</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand All @@ -43,7 +43,7 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.3.22</version>
<version>5.3.23</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
Expand All @@ -54,7 +54,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>2.0.1</version>
<version>2.0.3</version>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
Expand All @@ -64,7 +64,7 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.3.22</version>
<version>5.3.23</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
Expand All @@ -79,7 +79,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
<version>2.7.3</version>
<version>2.7.4</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
main.title=V�tejte ve slu?b? Moje dokumenty
main.menu.1=Zobrazit v?echny Moje dokumenty
main.menu.2=Zobrazit v?echny typy dokument?
main.menu.3=Vyhled�v�n� podle typu
main.menu.4=Odej�t

login.success=Tento u?ivatel je autorizovan�
login.failure=VAROV�N�! Tento u?ivatel nem� opr�vn?n�!
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Repository;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;

Expand All @@ -38,24 +40,22 @@ public void testScheduler() throws InterruptedException{
}

@Test
@Disabled
public void testEmail() throws InterruptedException{
log.debug("Testing Email...");
Assertions.assertNotNull(email);
long start = new Date().getTime();
email.send("ahoj@seznam.cz", "stemberk@spsmb.cz", "Hello World1!", "Hello There!!");
email.send("franta@seznam.cz", "stemberk@spsmb.cz", "Hello World1!", "Hello There!!");
long end = new Date().getTime();
long time = (end - start)/1000;
log.debug("Sending email done. Took: " + time + " seconds.");
}

@Test
@Disabled
public void testAsyncEmail() throws InterruptedException{
log.debug("Testing Async Email...");
Assertions.assertNotNull(email);
long start = new Date().getTime();
email.sendAsync("ahoj@seznam.cz", "stemberk@spsmb.cz", "Hello World Async, 2. pokus!", "Hello There!!");
email.sendAsync("franta@seznam.cz", "stemberk@spsmb.cz", "Hello World Async, 2. pokus!", "Hello There!!");
long end = new Date().getTime();
long time = (end - start)/1000;
log.debug("Sending Async email done. Took: " + time + " seconds.");
Expand Down
39 changes: 35 additions & 4 deletions src/cz/spsmb/ctvrtak/e_javafx/hry/a_zaklady/b_animace/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class Board extends javafx.animation.AnimationTimer {
private Image star;
// private Timer timer;
private int x, y;
private int x_velocity, y_velocity;
private Canvas canvas;

public Board() {
Expand All @@ -37,12 +38,23 @@ public Canvas getCanvas() {

@Override
public void handle(long l) {
x += 1;
y += 1;
x += x_velocity;
y += y_velocity;

if (y > B_HEIGHT) {
y = INITIAL_Y;
x = INITIAL_X;
y_velocity = -y_velocity;
}

if(x > B_WIDTH) {
x_velocity = -x_velocity;
}

if (y < 0) {
y_velocity = -y_velocity;
}

if (x < 0) {
x_velocity = -x_velocity;
}
this.drawStar();
}
Expand All @@ -59,9 +71,28 @@ private void initBoard() {
loadImage();
x = INITIAL_X;
y = INITIAL_Y;

setRandomVelocity();
}

private void setRandomVelocity(){
if(x_velocity < 0){
x_velocity = (int) (Math.random() * 10);
} else {
x_velocity = (int) (Math.random() * 10) * -1;
}

if(y_velocity < 0){
y_velocity = (int) (Math.random() * 10);
} else {
y_velocity = (int) (Math.random() * 10) * -1;
}
}
private void drawStar() {
GraphicsContext gc = canvas.getGraphicsContext2D();
gc.setFill(Color.BLACK);
gc.fillRect(0,0, canvas.getWidth(), canvas.getHeight());

gc.drawImage(star, x, y);
gc.setLineWidth(2);
gc.setStroke(Color.BLACK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,33 @@ public void handle(long l) {
private void step() {
spaceShip.move();
GraphicsContext gc = canvas.getGraphicsContext2D();
gc.setFill(javafx.scene.paint.Color.BLACK);
gc.fillRect(0,0,canvas.getWidth(),canvas.getHeight());

for (Projectile p : spaceShip.getProjectiles()) {
if(p.getX() > canvas.getWidth() || p.getX() < 0 || p.getY() > canvas.getHeight() || p.getY() < 0) {
spaceShip.getProjectiles().remove(p);
continue;
}
for (Enemy e : spaceShip.getEnemies()) {
if (p.getX() + p.getHeight() >= e.getX() - e.getWidth() && p.getX() - p.getHeight() <= e.getX() + e.getWidth() && p.getY() + p.getWidth() >= e.getY() - e.getHeight() && p.getY() - p.getWidth() <= e.getY() + e.getHeight()) {
gc.drawImage(e.getExplosion(), e.getX(), e.getY());
spaceShip.getEnemies().remove(e);
spaceShip.getProjectiles().remove(p);
}
}
p.move();
gc.drawImage(p.getImage(), p.getX(), p.getY());
}

for(Enemy e : spaceShip.getEnemies()) {
gc.drawImage(e.getImage(), e.getX(), e.getY());
}


gc.drawImage(spaceShip.getImage(), spaceShip.getX(), spaceShip.getY());
//repaint(spaceShip.getX()-1, spaceShip.getY()-1,
// spaceShip.getWidth()+2, spaceShip.getHeight()+2);
}

/*
private class TAdapter extends KeyAdapter {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package cz.spsmb.ctvrtak.e_javafx.hry.a_zaklady.c_pohyb_spritu;

import javafx.scene.image.Image;

public class Enemy {
int x, y;
int dx, dy;
int width, height;
Image image;
Image explosion;

public Enemy(int x, int y) {
this.x = x;
this.y = y;
this.image = new Image("alien.png");
this.explosion = new Image("star.png");
this.width = (int) image.getWidth();
this.height = (int) image.getHeight();
}

public int getX() {
return x;
}

public int getY() {
return y;
}

public int getDx() {
return dx;
}

public int getDy() {
return dy;
}

public int getWidth() {
return width;
}

public int getHeight() {
return height;
}

public Image getImage() {
return image;
}

public Image getExplosion() {
return explosion;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package cz.spsmb.ctvrtak.e_javafx.hry.a_zaklady.c_pohyb_spritu;
import javafx.scene.image.Image;

public class Projectile {
private int x, y;
private int dx, dy;
private int width, height;
private Image image;

public Projectile(int x, int y, int dx, int dy) {
this.x = x;
this.y = y;
this.dx = dx;
this.dy = dy;
this.image = new Image("missile.png");
this.width = (int) image.getWidth();
this.height = (int) image.getHeight();
}

public void move() {
x += dx;
y += dy;
}

public int getX() {
return x;
}

public int getY() {
return y;
}

public int getDx() {
return dx;
}

public int getDy() {
return dy;
}

public int getWidth() {
return width;
}

public int getHeight() {
return height;
}

public Image getImage() {
return image;
}
}



Loading