Created
July 22, 2022 22:03
-
-
Save FoxSamu/846bdeaaeeabb00f5af292bc5fae2cc9 to your computer and use it in GitHub Desktop.
Translating random chunks of my Java code to Dutch: MuisBasis
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
// Original | |
package net.shadew.ui.input; | |
import net.shadew.ui.util.Box; | |
public class MouseBase implements Mouse { | |
private final InputSource inputSource; | |
private float originX; | |
private float originY; | |
private boolean hasInput; | |
private boolean consumed; | |
public MouseBase(InputSource inputSource) { | |
this.inputSource = inputSource; | |
} | |
public void enable(boolean enable) { | |
hasInput = enable; | |
consumed = false; | |
} | |
public void origin(float x, float y) { | |
originX = x; | |
originY = y; | |
} | |
@Override | |
public float mouseX() { | |
return inputSource.mouseX() - originX; | |
} | |
@Override | |
public float mouseY() { | |
return inputSource.mouseY() - originY; | |
} | |
@Override | |
public boolean mouseDown(int button) { | |
return hasInput() && inputSource.isMouseDown(button); | |
} | |
@Override | |
public boolean mouseInside(float w, float h) { | |
if (!hasInput()) return false; | |
float mx = mouseX(); | |
float my = mouseY(); | |
return mx >= 0 && mx < w && my >= 0 && my < h; | |
} | |
@Override | |
public boolean mouseInside(float x, float y, float w, float h) { | |
if (!hasInput()) return false; | |
float mx = mouseX() - x; | |
float my = mouseY() - y; | |
return mx >= 0 && mx < w && my >= 0 && my < h; | |
} | |
@Override | |
public boolean mouseInside(Box box) { | |
if (!hasInput()) return false; | |
return box.inside(mouseX(), mouseY()); | |
} | |
@Override | |
public void consume() { | |
consumed = true; | |
} | |
@Override | |
public void reenable() { | |
consumed = false; | |
} | |
@Override | |
public boolean hasInput() { | |
return hasInput && !consumed; | |
} | |
} |
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
pakket net.shadew.gi.invoer; | |
importeer net.shadew.gi.gereedschappen.Rechthoek; | |
publieke klasse Muisbasis implementeert Muis { | |
privé finale Invoerbron invoerbron; | |
privé drijf oorsprongX; | |
privé drijf oorsprongY; | |
privé waarheid heeftInvoer; | |
privé waarheid geconsumeerd; | |
publieke Muisbasis(Invoerbron invoerbron) { | |
dit.invoerbron = invoerbron; | |
} | |
publieke leegte inschakelen(waarheid inschakelen) { | |
heeftInvoer = inschakelen; | |
geconsumeerd = niet; | |
} | |
publieke leegte oorsrpong(drijf x, drijf y) { | |
oorsprongX = x; | |
oorsprongY = y; | |
} | |
@Overschrijf | |
publieke drijf muisX() { | |
stuur invoerbron.muisX() - oorsprongX terug; | |
} | |
@Overschrijf | |
publieke drijf muisY() { | |
stuur invoerbron.muisY() - oorsprongY terug; | |
} | |
@Overschrijf | |
publieke waarheid muisIngedrukt(geheel knop) { | |
stuur heeftInvoer() && invoerbron.isMuisIngedrukt(knop) terug; | |
} | |
@Overschrijf | |
publieke waarheid bevatMuis(drijf b, drijf h) { | |
if (!heeftInvoer()) stuur niet terug; | |
drijf mx = muisX(); | |
drijf my = muisY(); | |
stuur mx >= 0 && mx < b && my >= 0 && my < h terug; | |
} | |
@Overschrijf | |
publieke waarheid bevatMuis(drijf x, drijf y, drijf b, drijf h) { | |
if (!heeftInvoer()) stuur niet terug; | |
drijf mx = muisX() - x; | |
drijf my = muisY() - y; | |
stuur mx >= 0 && mx < b && my >= 0 && my < h terug; | |
} | |
@Overschrijf | |
publieke waarheid bevatMuis(Rechthoek rechthoek) { | |
if (!heeftInvoer()) stuur niet terug; | |
stuur rechthoek.bevat(muisX(), muisY()) terug; | |
} | |
@Overschrijf | |
publieke leegte consumeren() { | |
geconsumeerd = wel; | |
} | |
@Overschrijf | |
publieke leegte herinschakelen() { | |
geconsumeerd = niet; | |
} | |
@Overschrijf | |
publieke waarheid heeftInvoer() { | |
stuur heeftInvoer && !geconsumeerd terug; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment