Skip to content
Snippets Groups Projects
Commit 6c210bdc authored by jez04's avatar jez04
Browse files

initial source code

parent 856248e4
Branches main
No related merge requests found
Pipeline #2389 failed with stages
Showing
with 1171 additions and 93 deletions
# https://editorconfig.org
root = true
[*]
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.{java,scala,groovy,kt,kts}]
indent_size = 4
[*.gradle]
indent_size = 2
[*.md]
trim_trailing_whitespace = false
* text=auto eol=lf
*.bat text=auto eol=crlf
## Gradle:
.gradle/
gradle-app.setting
/gradle/gradle-daemon-jvm.properties
/build/
/android/build/
/core/build/
/lwjgl2/build/
/lwjgl3/build/
/html/build/
/teavm/build/
/ios/build/
/ios-moe/build/
/headless/build/
/server/build/
/shared/build/
## Java:
*.class
*.war
*.ear
hs_err_pid*
.attach_pid*
## Android:
/android/libs/armeabi-v7a/
/android/libs/arm64-v8a/
/android/libs/x86/
/android/libs/x86_64/
/android/gen/
/android/out/
local.properties
com_crashlytics_export_strings.xml
## Robovm:
/ios/robovm-build/
## iOS:
/ios/xcode/*.xcodeproj/*
!/ios/xcode/*.xcodeproj/xcshareddata
!/ios/xcode/*.xcodeproj/project.pbxproj
/ios/xcode/native/
/ios/IOSLauncher.app
/ios/IOSLauncher.app.dSYM
## GWT:
/html/war/
/html/gwt-unitCache/
.apt_generated/
/html/war/WEB-INF/deploy/
/html/war/WEB-INF/classes/
.gwt/
gwt-unitCache/
www-test/
.gwt-tmp/
## TeaVM:
# Not sure yet...
## IntelliJ, Android Studio:
.idea/
*.ipr
*.iws
*.iml
## Eclipse:
.classpath
.project
.metadata/
/android/bin/
/core/bin/
/lwjgl2/bin/
/lwjgl3/bin/
/html/bin/
/teavm/bin/
/ios/bin/
/ios-moe/bin/
/headless/bin/
/server/bin/
/shared/bin/
*.tmp
*.bak
*.swp
*~.nib
.settings/
.loadpath
.externalToolBuilders/
*.launch
## NetBeans:
/nbproject/private/
/android/nbproject/private/
/core/nbproject/private/
/lwjgl2/nbproject/private/
/lwjgl3/nbproject/private/
/html/nbproject/private/
/teavm/nbproject/private/
/ios/nbproject/private/
/ios-moe/nbproject/private/
/headless/nbproject/private/
/server/nbproject/private/
/shared/nbproject/private/
/nbbuild/
/android/nbbuild/
/core/nbbuild/
/lwjgl2/nbbuild/
/lwjgl3/nbbuild/
/html/nbbuild/
/teavm/nbbuild/
/ios/nbbuild/
/ios-moe/nbbuild/
/headless/nbbuild/
/server/nbbuild/
/shared/nbbuild/
/dist/
/android/dist/
/core/dist/
/lwjgl2/dist/
/lwjgl3/dist/
/html/dist/
/teavm/dist/
/ios/dist/
/ios-moe/dist/
/headless/dist/
/server/dist/
/shared/dist/
/nbdist/
/android/nbdist/
/core/nbdist/
/lwjgl2/nbdist/
/lwjgl3/nbdist/
/html/nbdist/
/teavm/nbdist/
/ios/nbdist/
/ios-moe/nbdist/
/headless/nbdist/
/server/nbdist/
/shared/nbdist/
nbactions.xml
nb-configuration.xml
## OS-Specific:
.DS_Store
Thumbs.db
## Miscellaneous:
*~
*.*#
*#*#
/.kotlin/
/assets/assets.txt
## Special cases:
## There is a resource-config.json file generated by nativeimage.gradle if you use Graal Native Image.
## Some usage may need extra resource configuration in a different file with the same name.
## You could also add that configuration to the text in nativeimage.gradle .
## You should delete or comment out the next line if you have configuration in a different resource-config.json .
**/resource-config.json
# GardenMadness
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin https://gitlab.vsb.cz/jez04/GardenMadness.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
- [ ] [Set up project integrations](https://gitlab.vsb.cz/jez04/GardenMadness/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
# GardenMadnes
A [libGDX](https://libgdx.com/) project generated with [gdx-liftoff](https://github.com/libgdx/gdx-liftoff).
This project was generated with a template including simple application launchers and an `ApplicationAdapter` extension that draws libGDX logo.
## Platforms
- `core`: Main module with the application logic shared by all platforms.
- `lwjgl3`: Primary desktop platform using LWJGL3; was called 'desktop' in older docs.
- `html`: Web platform using GWT and WebGL. Supports only Java projects.
- `teavm`: Experimental web platform using TeaVM and WebGL.
## Gradle
This project uses [Gradle](https://gradle.org/) to manage dependencies.
The Gradle wrapper was included, so you can run Gradle tasks using `gradlew.bat` or `./gradlew` commands.
Useful Gradle tasks and flags:
- `--continue`: when using this flag, errors will not stop the tasks from running.
- `--daemon`: thanks to this flag, Gradle daemon will be used to run chosen tasks.
- `--offline`: when using this flag, cached dependency archives will be used.
- `--refresh-dependencies`: this flag forces validation of all dependencies. Useful for snapshot versions.
- `build`: builds sources and archives of every project.
- `cleanEclipse`: removes Eclipse project data.
- `cleanIdea`: removes IntelliJ project data.
- `clean`: removes `build` folders, which store compiled classes and built archives.
- `eclipse`: generates Eclipse project data.
- `html:dist`: compiles GWT sources. The compiled application can be found at `html/build/dist`: you can use any HTTP server to deploy it.
- `html:superDev`: compiles GWT sources and runs the application in SuperDev mode. It will be available at [localhost:8080/html](http://localhost:8080/html). Use only during development.
- `idea`: generates IntelliJ project data.
- `lwjgl3:jar`: builds application's runnable jar, which can be found at `lwjgl3/build/libs`.
- `lwjgl3:run`: starts the application.
- `teavm:build`: builds the JavaScript application into the build/dist/webapp folder.
- `teavm:run`: serves the JavaScript application at http://localhost:8080 via a local Jetty server.
- `test`: runs unit tests (if any).
Note that most tasks that are not specific to a single project can be run with `name:` prefix, where the `name` should be replaced with the ID of a specific project.
For example, `core:clean` removes `build` folder only from the `core` project.
assets/bucket.png

25 KiB

assets/drop.png

3.07 KiB

assets/garden.png

408 KiB

assets/libgdx.png

2.4 KiB

This diff is collapsed.
assets/red-font1.png

339 KiB

assets/red-font2.png

381 KiB

assets/red-font3.png

418 KiB

assets/red-font4.png

98.9 KiB

buildscript {
repositories {
mavenCentral()
maven { url 'https://s01.oss.sonatype.org' }
gradlePluginPortal()
mavenLocal()
google()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' }
}
dependencies {
}
}
allprojects {
apply plugin: 'eclipse'
apply plugin: 'idea'
// This allows you to "Build and run using IntelliJ IDEA", an option in IDEA's Settings.
idea {
module {
outputDir file('build/classes/java/main')
testOutputDir file('build/classes/java/test')
}
}
}
configure(subprojects) {
apply plugin: 'java-library'
sourceCompatibility = 11
// From https://lyze.dev/2021/04/29/libGDX-Internal-Assets-List/
// The article can be helpful when using assets.txt in your project.
tasks.register('generateAssetList') {
inputs.dir("${project.rootDir}/assets/")
// projectFolder/assets
File assetsFolder = new File("${project.rootDir}/assets/")
// projectFolder/assets/assets.txt
File assetsFile = new File(assetsFolder, "assets.txt")
// delete that file in case we've already created it
assetsFile.delete()
// iterate through all files inside that folder
// convert it to a relative path
// and append it to the file assets.txt
fileTree(assetsFolder).collect { assetsFolder.relativePath(it) }.sort().each {
assetsFile.append(it + "\n")
}
}
processResources.dependsOn 'generateAssetList'
compileJava {
options.incremental = true
}
}
subprojects {
version = '$projectVersion'
ext.appName = 'GardenMadnes'
repositories {
mavenCentral()
maven { url 'https://s01.oss.sonatype.org' }
// You may want to remove the following line if you have errors downloading dependencies.
mavenLocal()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' }
maven { url 'https://jitpack.io' }
maven { url 'https://teavm.org/maven/repository/' }
}
}
eclipse.project.name = 'GardenMadnes' + '-parent'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
eclipse.project.name = appName + '-core'
dependencies {
api "com.badlogicgames.gdx-controllers:gdx-controllers-core:$gdxControllersVersion"
api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
api "com.badlogicgames.gdx:gdx:$gdxVersion"
if(enableGraalNative == 'true') {
implementation "io.github.berstanio:gdx-svmhelper-annotations:$graalHelperVersion"
}
}
package cz.vsb.kp;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.Fixture;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.physics.box2d.World;
public class Bucket {
private Sprite sprite;
private Body body;
public Fixture dnoFixture;
private Texture img;
private float centerX;
private float centerY;
private World world;
public Bucket(Texture img, float centerX, float centerY, World world) {
this.img = img;
sprite = new Sprite(img);
sprite.setOriginBasedPosition(img.getWidth() / 200f, img.getHeight() / 200f);
sprite.setOrigin(0, 0);
sprite.setSize(img.getWidth() / 100f, img.getHeight() / 100f);
this.centerX = centerX - 1;
this.centerY = centerY;
this.world = world;
createBody();
setVelocity(10);
}
private void createBody() {
int vyskaUchaKbeliku = 100;
PolygonShape dno = new PolygonShape();
dno.setAsBox(img.getWidth() / 200f, 0.02f, new Vector2(0, -img.getHeight() / 200f), 0);
PolygonShape stenaPrava = new PolygonShape();
stenaPrava.setAsBox(0.02f, (img.getHeight() - vyskaUchaKbeliku) / 200f,
new Vector2(img.getWidth() / 200f, -vyskaUchaKbeliku / 200f), 0);
PolygonShape stenaLeva = new PolygonShape();
stenaLeva.setAsBox(0.02f, (img.getHeight() - vyskaUchaKbeliku) / 200f,
new Vector2(-img.getWidth() / 200f, -vyskaUchaKbeliku / 200f), 0);
PolygonShape vnitrek = new PolygonShape();
vnitrek.setAsBox((img.getWidth() - 8) / 200f, ((img.getHeight() - vyskaUchaKbeliku) / 400f),
new Vector2(0, -vyskaUchaKbeliku / 200f - (img.getHeight() - vyskaUchaKbeliku) / 400f + 0.04f), 0);
FixtureDef detekceObsahu = new FixtureDef();
detekceObsahu.isSensor = true;
detekceObsahu.shape = vnitrek;
BodyDef def = new BodyDef();
def.type = BodyDef.BodyType.KinematicBody;
body = world.createBody(def);
dnoFixture = body.createFixture(dno, 0);
body.createFixture(stenaPrava, 0);
body.createFixture(stenaLeva, 0);
body.createFixture(detekceObsahu);
body.setTransform(centerX, centerY, 0);
dno.dispose();
stenaLeva.dispose();
stenaPrava.dispose();
vnitrek.dispose();
}
public float getX() {
return body.getPosition().x;
}
public float getY() {
return body.getPosition().y;
}
public float getWidth() {
return sprite.getWidth();
}
public float getHeigh() {
return sprite.getHeight();
}
public void setVelocity(float v) {
if (v < 5 && v > -5) {
body.setLinearVelocity(v, 0);
}
System.out.println(getVelocity());
}
public float getVelocity() {
return body.getLinearVelocity().x;
}
public void draw(SpriteBatch batch) {
sprite.setCenter(body.getPosition().x, body.getPosition().y);
sprite.setOrigin(sprite.getWidth() / 2, sprite.getHeight() / 2);
sprite.setRotation((float) (180 / Math.PI * body.getAngle()));
sprite.draw(batch);
// batch.draw(img, getX()-getWidth()/2, getY()-getHeigh()/2);
}
public void draw(ShapeRenderer shapeRenderer) {
// Color c = new Color(0, 1, 0, 0.5f);
// shapeRenderer.setColor(c);
// shapeRenderer.rect(body.getPosition().x-getWidth()/2, body.getPosition().y - getHeigh()/2, getWidth(), getHeigh());
// Color c1 = new Color(1, 1, 0, 0.5f);
// shapeRenderer.setColor(c1);
// shapeRenderer.rect(body.getPosition().x-getWidth()/2 + 10, body.getPosition().y - getHeigh()/2 + 10, getWidth() - 20, getHeigh() - 20);
}
public boolean isInside(Drop drop) {
Rectangle bucket = new Rectangle(centerX - getWidth() / 2, centerY / getHeigh() / 2, getWidth(), getHeigh());
Rectangle dropRect = new Rectangle(centerX, centerY, centerY, centerX);
return bucket.overlaps(dropRect);
}
}
package cz.vsb.kp;
import com.badlogic.gdx.physics.box2d.Contact;
import com.badlogic.gdx.physics.box2d.ContactImpulse;
import com.badlogic.gdx.physics.box2d.ContactListener;
import com.badlogic.gdx.physics.box2d.Manifold;
public class ContactDetector implements ContactListener {
@Override
public void beginContact(Contact contact) {
Drop kapka = isDropInContactWithSenzor(contact);
if (kapka != null) {
kapka.setZmensovani(true);
}
}
private Drop isDropInContactWithSenzor(Contact contact) {
if (contact.getFixtureA().isSensor() || contact.getFixtureB().isSensor()) {
if (contact.getFixtureA().getBody().getUserData() instanceof Drop) {
Drop d = (Drop) contact.getFixtureA().getBody().getUserData();
return (Drop) contact.getFixtureA().getBody().getUserData();
}
if (contact.getFixtureB().getBody().getUserData() instanceof Drop) {
return (Drop) contact.getFixtureB().getBody().getUserData();
}
System.out.println("kontak");
}
return null;
}
@Override
public void endContact(Contact contact) {
Drop kapka = isDropInContactWithSenzor(contact);
if (kapka != null) {
kapka.setZmensovani(false);
}
}
@Override
public void preSolve(Contact contact, Manifold oldManifold) {
// TODO Auto-generated method stub
}
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
// TODO Auto-generated method stub
}
}
package cz.vsb.kp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.CircleShape;
import com.badlogic.gdx.physics.box2d.Fixture;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.World;
import com.badlogic.gdx.utils.Array;
public class Drop {
private static final Random random = new Random();
private List<String> imgNames = Arrays.asList("aa", "sddd");
private Body body;
private Texture dropImg;
private Sprite sprite;
private float centerX;
private float centerY;
private World world;
private float radius;
private boolean zmensovani = false;
private FruitType fruitType;
public Drop(Texture dropImg, float centerX,
float centerY, World world) {
int points = 8447;
int tisice = points/1000;
// Integer.toString(he)
// FruitType[] arrayOfFruitsType = FruitType.values();
// int fruitTypeSize =arrayOfFruitsType.length;
// int randomIndexOfFruit = random.nextInt(fruitTypeSize);
// fruitType = arrayOfFruitsType[randomIndexOfFruit];
this.dropImg = dropImg;
radius = 0.2f;
// radius = fruitType.getSize() / 20f;
sprite = new Sprite(dropImg);
sprite.setOriginBasedPosition(dropImg.getWidth() / 200f, dropImg.getHeight() / 200f);
sprite.setOrigin(0, 0);
this.centerX = centerX;
this.centerY = centerY;
this.world = world;
createBody();
body.setLinearVelocity(2 - random.nextFloat() * 2, 0);
}
private void createBody() {
BodyDef def = new BodyDef();
def.type = BodyDef.BodyType.DynamicBody;
body = world.createBody(def);
createNewBodyFixture(radius);
body.setTransform(centerX, centerY, 0);
// body.setGravityScale(0);
body.setUserData(this);
body.setGravityScale(0.1f);
}
private void createNewBodyFixture(float radius) {
CircleShape poly = new CircleShape();
poly.setRadius(radius);
FixtureDef fixtureDef = new FixtureDef();
fixtureDef.shape = poly;
fixtureDef.density = 5.5f;
fixtureDef.friction = 0.1f;
fixtureDef.restitution = 0.2f; // Make it bounce a little bit
body.createFixture(fixtureDef);
poly.dispose();
}
public void switchGravityOff() {
body.setGravityScale(0);
}
public void switchGravityOn() {
body.setGravityScale(0.1f);
}
public void update() {
if(zmensovani) {
zmensi();
}
}
public boolean isZmensovani() {
return zmensovani;
}
public void setZmensovani(boolean zmensovani) {
this.zmensovani = zmensovani;
}
public void zmensi() {
// for (Fixture fixture : body.getFixtureList()) {
// body.destroyFixture(fixture);
// }
CircleShape c = (CircleShape)body.getFixtureList().get(0).getShape();
c.setRadius(c.getRadius()- 0.005f);
radius = radius - 0.005f;
// System.out.println("zmenseni" + radius);
// if(Math.random()> 0.95) {
// c.setRadius(c.getRadius()+0.5f);
// }
if (radius <0.08) {
// System.out.println("destroy");
world.destroyBody(body);
}
}
public float getX() {
return body.getPosition().x;
}
public float getY() {
return body.getPosition().y;
}
public float getWidth() {
return dropImg.getWidth();
}
public float getHeigh() {
return dropImg.getHeight();
}
public void draw(SpriteBatch batch) {
sprite.setSize(radius*2, radius*2);
sprite.setCenter(body.getPosition().x, body.getPosition().y);
sprite.setOrigin(sprite.getWidth() / 2, sprite.getHeight() / 2);
sprite.setRotation((float) (180 / Math.PI * body.getAngle()));
sprite.draw(batch);
// batch.draw(dropImg, getX() - getWidth()/2, getY() - getHeigh()/2);
}
}
package cz.vsb.kp;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Box2DDebugRenderer;
import com.badlogic.gdx.physics.box2d.World;
public class DropGame extends Game {
SpriteBatch batch;
BitmapFont font;
ShapeRenderer shapeRenderer;
@Override
public void create() {
font = new BitmapFont(Gdx.files.internal("red-font.fnt"));
font.getData().setScale(1f);
batch = new SpriteBatch();
shapeRenderer = new ShapeRenderer();
setScreen(new MainMenuScreen(this));
}
@Override
public void dispose() {
batch.dispose();
font.dispose();
shapeRenderer.dispose();
}
}
package cz.vsb.kp;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Rectangle;
public class Food {
Rectangle rect;
public Food(int x, int y) {
rect = new Rectangle(x, y, 48, 48);
}
public void fallDown() {
rect.y = rect.y - 1;
}
public static void main(String[] args) {
new Food(MathUtils.random(0), 480);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment