-
-
Save sinistersnare/7e47ab1e743b8c0c6899 to your computer and use it in GitHub Desktop.
jythongdx help...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.badlogic.gdx.Gdx | |
import com.badlogic.gdx.ApplicationListener | |
from com.badlogic.gdx.graphics.g2d import SpriteBatch, TextureRegion, Sprite | |
from com.badlogic.gdx.graphics import Texture, OrthographicCamera, GL10 | |
import com.badlogic.gdx.graphics.Texture.TextureFilter | |
class GdxJython(ApplicationListener): | |
def __init__(self): | |
self.camera = None | |
self.batch = None | |
self.texture = None | |
self.sprite = None | |
def create(self): | |
w = Gdx.graphics.getWidth() | |
h = Gdx.graphics.getHeight() | |
self.camera = OrthographicCamera(1, h/w) | |
batch = SpriteBatch() | |
texture = Texture(Gdx.files.internal("data/libgdx.png")) | |
texure.setFilter(TextureFilter.Linear, TextureFilter.Linear) | |
region = TextureRegion(texture, 0, 0, 512, 275) | |
sprite = Sprite(region) | |
sprite.setSize(0.9,0.9 * sprite.getHeight() / sprite.getWidth() ) | |
sprite.setOrigin(sprite.getWidth()/2, sprite.getHeight()/2); | |
sprite.setPosition(-sprite.getWidth()/2, -sprite.getHeight()/2); | |
def dispose(self): | |
batch.dispose() | |
texture.dispose() | |
def render(self): | |
Gdx.gl.glClearColor(1,1,1,1) | |
Gdx.gl.GlClear(GL10.GL_COLOR_BUFFER_BIT) | |
batch.setProjectionMatrix(camera.combined) | |
batch.begin() | |
sprite.draw(batch) | |
batch.end() | |
def resize(self, width, height): | |
pass | |
def pause(self): | |
pass | |
def resume(self): | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.badlogic.GdxJython; | |
import com.badlogic.gdx.backends.lwjgl.LwjglApplication; | |
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; | |
public class Main { | |
public static void main(String[] args) { | |
LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration(); | |
cfg.title = "GdxJython"; | |
cfg.useGL20 = false; | |
cfg.width = 480; | |
cfg.height = 320; | |
new LwjglApplication(new GdxJython(), cfg); | |
//need to replace the ```new GdxJython()``` with a call to the class in gdx.py | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment