id
stringlengths 36
36
| text
stringlengths 1
1.25M
|
---|---|
8c7d0ecc-a922-4e12-b878-d6f75a3fd47d
|
public int getY() {
return this.y;
}
|
f3a275e5-7912-4a79-bea1-ccbf442290fe
|
public void setY(int y) {
this.y = y;
}
|
c2c827b9-8020-4482-b13f-254fcf6f33ae
|
public int getWidth() {
return this.width;
}
|
187bacf4-1aa2-462b-8cbb-f2ce5372c210
|
public void setWidth(int width) {
this.width = width;
}
|
cf5d5b08-72f5-4e92-84b2-518cabbab352
|
public int getHeight() {
return this.height;
}
|
c8963fb8-838b-4ada-ae2a-a5189f88de94
|
public void setHeight(int height) {
this.height = height;
}
|
97ed94b1-07d0-47b1-ad1c-2f67b8bc2e39
|
public int getSpeed() {
return this.speed;
}
|
393145d4-27fa-46a4-9ef7-5c796436a666
|
public void setSpeed(int speed) {
this.speed = speed;
}
|
651fffb1-caf6-49eb-bb71-ce5fefea5294
|
public Image getImage() {
return this.image;
}
|
50937e44-ab10-4a7f-a3be-5e9de4906766
|
public void setImage(Image image) {
this.image = image;
}
|
fda12bf8-486a-496f-844d-160dc643e14b
|
public ObjectBounds getBounds() {
return this.bounds;
}
|
4b3cae76-8b60-4437-b782-0a2a77e1c1a0
|
public void setBounds(ObjectBounds bounds) {
this.bounds = bounds;
}
|
7fcd36a3-dee5-4c04-97d1-8c16d6f6d170
|
public boolean isLimitedToScreenBounds() {
return this.limitToScreenBounds;
}
|
abf5b10e-4893-4daf-befe-87d135769181
|
public void limitToScreenBounds(boolean limit) {
this.limitToScreenBounds = limit;
}
|
44cb1830-9c39-4107-be50-d815f12b765b
|
public int getPanelWidth() {
return this.panelWidth;
}
|
b66190ba-2788-4557-98ea-3083f271487b
|
public void setPanelWidth(int panelWidth) {
this.panelWidth = panelWidth;
}
|
535f7196-53fc-4ae0-b083-f37724f2ed98
|
public int getPanelHeight() {
return this.panelHeight;
}
|
14f5ca21-4eb8-4c42-9434-f8668a7f0ad9
|
public void setPanelHeight(int panelHeight) {
this.panelHeight = panelHeight;
}
|
1d074ab8-2894-456c-9303-1a59b786a5f3
|
public void setPanelSize(int panelWidth, int panelHeight) {
this.panelWidth = panelWidth;
this.panelHeight = panelHeight;
}
|
1c085e1e-ebc7-406b-8423-f7a4d424d516
|
public void setBoundsBySize() {
ArrayList<Point> points = new ArrayList<Point>();
for(int y = 0; y < this.height; y++) {
for(int x = 0; x < this.width; x++) {
points.add(new Point(x, y));
}
}
this.bounds = new ObjectBounds(points);
}
|
058a5059-7daa-44bf-a549-f2b92d70fa22
|
public void advanceX(Direction direction) {
if(limitToScreenBounds) {
if(direction == Direction.LEFT) {
if((this.x - speed) < 0) {
// Prevent movement, object is at min screen bounds
return;
}
} else if(direction == Direction.RIGHT) {
if((this.x + speed) > (this.panelWidth - this.width)) {
// Prevent movement, object is at max screen bounds
return;
}
}
}
if(direction == Direction.LEFT) {
this.x -= speed;
} else if(direction == Direction.RIGHT) {
this.x += speed;
} else {
System.out.println("Unsupported direction for x axis!");
}
this.bounds.setElevation(this.x, this.y);
}
|
7b7c00c5-3c6f-49fa-8c7c-3046be309cc5
|
public void advanceY(Direction direction) {
if(limitToScreenBounds) {
if(direction == Direction.UP) {
if((this.y - speed) < 0) {
// Prevent movement, object is at min screen bounds
return;
}
} else if(direction == Direction.DOWN) {
if((this.y + speed) > (this.panelHeight - this.height)) {
// Prevent movement, object is at max screen bounds
return;
}
}
}
if(direction == Direction.UP) {
this.y -= speed;
} else if(direction == Direction.DOWN) {
this.y += speed;
} else {
System.out.println("Unsupported direction for y axis!");
}
this.bounds.setElevation(this.x, this.y);
}
|
1dd7e0f0-60da-4432-9d3e-6a4fd133b4bb
|
public void setSizeByImage() {
this.width = image.getWidth(null);
this.height = image.getHeight(null);
}
|
dad5f453-5928-43f0-8b29-8b6ebb6baaf5
|
public boolean isOutsideScreen(Direction direction) {
if(direction == Direction.DOWN) {
if(this.y > this.panelHeight) {
return true;
}
} else if(direction == Direction.UP) {
if((this.y + this.height) < 0) {
return true;
}
}
return false;
}
|
062233b3-f68a-411b-a2a6-2336db1b3da7
|
public static int randomWithRange(int min, int max)
{
int range = (max - min) + 1;
return (int)(Math.random() * range) + min;
}
|
db9593b5-b78c-4502-895a-c9d15194102c
|
public Point() { }
|
951d07b4-1783-4f69-a547-37af28ce78d5
|
public Point(int x, int y) {
this.x = x;
this.y = y;
}
|
fbdc32f6-6da3-4bca-993b-f9ad13665522
|
public int getX() {
return this.x;
}
|
bdf31ddb-cfe5-458e-bc1a-090491bf927b
|
public int getY() {
return this.y;
}
|
f56e673e-3c6a-4461-8f60-deb15ebf72d7
|
public void setX(int x) {
this.x = x;
}
|
ad109e2f-1f25-4d54-a583-3487b9f8ddfc
|
public void setY(int y) {
this.y = y;
}
|
4d0bef03-b75e-4b76-82d1-7bd4a45f420b
|
public boolean isBigger(Point p) {
if(this.x > p.x && this.y > p.y) {
return true;
}
return false;
}
|
7b8eb997-f75c-402f-b38c-d5dd3b38f58d
|
public boolean isSmaller(Point p) {
if(this.x < p.x && this.y < p.y) {
return true;
}
return false;
}
|
6797b21e-7b83-483a-8032-80b76ccfabf9
|
public BasePage(WebDriver driver){
this.webDriver = driver;
PageFactory.initElements(webDriver, this);
}
|
bb63da35-ed70-4e1b-8574-5fbf126583f2
|
public void chooseJava(String category, String language, String value){
$(categoryDrpdwn).selectOption(category);
$(languageDrpdwn).shouldHave(Condition.hasText(language)).selectOption(language);
$(values).setValue(value);
$(codeInItBtn).click();
}
|
8d39baae-9e13-46d5-9570-33eda8084496
|
public BasicAjaxPage(WebDriver driver) {
super(driver);
}
|
9be601f0-4fbf-49a7-9fc6-20bfe19b4ea8
|
public void clickShowAlertBoxPageBtn() {
$(showAlertBoxPageBtn).shouldBe(Condition.visible).click();
}
|
9fb0b8e5-070f-4ab4-953d-337eb4cac47d
|
public AlertPage(WebDriver driver) {
super(driver);
}
|
26d1d851-5d40-427a-9d42-eac12e993d5a
|
public void chooseRequiredByFullName(String fullName){
SelenideElement element = $(By.xpath("//ul[@id = 'optional_listbox']/li[contains(text(), '" + fullName + "')]"));
multiSelectOptional.click();
element.click();
}
|
ef066e42-27dc-4f11-b2f8-cbb2ba8583d1
|
public void deleteChoosenByFullName(String fullName){
SelenideElement element
= $(By.xpath("//ul[@id = 'required_taglist']/li/span[contains(text(), '" + fullName + "')]/following-sibling::span"));
element.click();
}
|
410b6d58-f89f-4d3d-bbd2-7291f672f37f
|
public void clickSendInvitationBtn() {
$(sendInvitationBtn).shouldBe(Condition.enabled).click();
}
|
5dc2f0dc-c0da-48aa-975f-baba969936f2
|
public KendouiMultiselectPage(WebDriver driver) {
super(driver);
}
|
4c02a9b1-1013-44ff-9aa2-3682852872ef
|
public WebElement getTableRaw() {
return tableRaw;
}
|
f1e40834-53c7-4ac9-b8a8-7721cd5a1232
|
public int getCountOfRowsInTable (String xpath){
List<WebElement> rows = webDriver.findElements(By.xpath(xpath));
return rows.size() ;
}
|
69ca827c-7457-4edc-bf6d-cd6dbab7faaa
|
public void choseAndApplyFilter(String nameOfColumn,String nameCondition, String inputValue ) {
clickOnChoosenFilter(nameOfColumn);
chooseFilterAction(nameCondition, inputValue);
}
|
c4b136fc-0dc2-40a2-b4b9-99c61b258114
|
public void chooseFilterAction(String nameConditions, String inputValue) {
builder = new Actions(webDriver);
builder.click(condition);
builder.sendKeys(condition,nameConditions);
builder.sendKeys(input, inputValue);
builder.click(submitBtn);
Action filter = builder.build();
filter.perform();
}
|
c84cbae5-3b9b-4bac-b247-4db8df7d19c7
|
private void clickOnChoosenFilter(String nameOfColumn) {
SelenideElement filter =
$(By.xpath("//div[@id = 'grid']//thead//th[@data-field = '" + nameOfColumn + "']/a"));
filter.click();
}
|
69f60b86-46a6-43f0-a087-335d6ae79086
|
public FilterMenuCustomizationPage(WebDriver driver) {
super(driver);
}
|
bf781224-9166-43aa-8c56-74ac7c9a6eeb
|
@Test
public void verifyMultiSelect() {
KendouiMultiselectPage kendouiMultiselectPage = new KendouiMultiselectPage(getWebDriver());
kendouiMultiselectPage.chooseRequiredByFullName("Nancy Davolio");
kendouiMultiselectPage.deleteChoosenByFullName("Andrew Fuller");
kendouiMultiselectPage.clickSendInvitationBtn();
//home
}
|
386d758c-e26d-43c9-b6ff-2a668ae81dad
|
@Override
protected String getUrl(){
return "web/multiselect/index.html";
}
|
3249bead-b949-436a-94be-5336c247992a
|
@Test
public void verifyBasicAjax() {
BasicAjaxPage basicAjaxPage = new BasicAjaxPage(getWebDriver());
basicAjaxPage.chooseJava("Server","Cobol","1");
}
|
bd439e60-c26c-45ec-945f-852b15b81a07
|
@Override
protected String getUrl(){
return "/basic_ajax.html";
}
|
6fb425ce-8516-49d4-8964-e0232056a398
|
@Test
public void verifyFilter() {
FilterMenuCustomizationPage filterMenuCustomizationPage = new FilterMenuCustomizationPage(getWebDriver());
filterMenuCustomizationPage.choseAndApplyFilter("Title", "Is equal to","Web Designer");
int i = filterMenuCustomizationPage.getCountOfRowsInTable("//div[@id = 'grid']//tbody/tr");
System.out.println(i);
}
|
44f62bd5-c6cb-4590-a623-1b674bd62bd8
|
@Override
protected String getUrl() {
return "web/grid/filter-menu-customization.html";
}
|
b9bf715a-e8b6-41e8-939d-0faccedb64b2
|
public WebDriver getWebDriver() {
return driver;
}
|
dc172d15-7b57-4c89-b099-c447e67cb5cd
|
@BeforeClass
public void SetUp(){
System.out.println("webdriver init");
driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
WebDriverRunner.setWebDriver(driver);
Configuration.timeout = 4000;
//getWebdriver().get("http://compendiumdev.co.uk/selenium" + getUrl());
driver.get("http://demos.kendoui.com/" + getUrl());
}
|
8c797f36-efcf-4274-91e2-249271aa726b
|
protected String getUrl(){
return "/";
}
|
ca3a7087-f447-4802-a859-658ca142986b
|
@Test
public void verifyAlert() {
AlertPage alertPage = new AlertPage(getWebDriver());
alertPage.clickShowAlertBoxPageBtn();
}
|
d2e026ba-d8f0-446a-9a04-e1f25eef4e05
|
@Override
protected String getUrl(){
return "/alert.html";
}
|
1e52ba7d-fd42-4768-be90-0447fff93081
|
public Estoque() {
Cerveja cvj1 = new Cerveja("Stella Artois", "A cerveja belga mais francesa do mundo", "Artois", Tipo.LAGER);
Cerveja cvj2 = new Cerveja("Erdinger Weissbier", "Cerveja de trigo alemã", "Erdinger Weissbrau", Tipo.WEIZEN);
this.cervejas.put(cvj1.getNome(), cvj1);
this.cervejas.put(cvj2.getNome(), cvj2);
}
|
6950c5ab-2422-43ee-b11f-9d21dfd24009
|
public Collection<Cerveja> listarCervejas(){
return new ArrayList<Cerveja>(this.cervejas.values());
}
|
0d34a594-729d-4695-8f2b-9034f51796c1
|
public void adicionarCerveja(Cerveja cerveja){
this.cervejas.put(cerveja.getNome(), cerveja);
}
|
048f7e1c-ee4e-46d0-b4df-32a418f9537a
|
public Cerveja recuperarCervejaPeloNome(String nome){
return this.cervejas.get(nome);
}
|
d0edda54-51f8-45b5-8d4b-0a02b511de75
|
public Cerveja() {
// TODO Auto-generated constructor stub
}
|
bff2c483-7c18-49c3-8854-0d5d5cc77801
|
public Cerveja(String nome, String descricao, String cervejaria, Tipo tipo) {
super();
this.nome = nome;
this.descricao = descricao;
this.cervejaria = cervejaria;
this.tipo = tipo;
}
|
b6ac5157-690c-4c38-b9a7-00a0d82f8088
|
public String getNome() {
return nome;
}
|
a3a18cff-0457-46e4-bfd3-912c90ead3a3
|
public void setNome(String nome) {
this.nome = nome;
}
|
3c82fdae-b014-499f-9a71-31a1b8e0a55f
|
public String getDescricao() {
return descricao;
}
|
9a0ca503-04ae-4827-abb5-70e1bd8c1e39
|
public void setDescricao(String descricao) {
this.descricao = descricao;
}
|
8bd36c88-2c99-4c8b-b28d-5e96b9b09bad
|
public String getCervejaria() {
return cervejaria;
}
|
a97ff98a-642f-49dc-90f2-8d93e5f3cad7
|
public void setCervejaria(String cervejaria) {
this.cervejaria = cervejaria;
}
|
f6d185b1-04d2-4c96-a225-462f6d6b6ce1
|
public Tipo getTipo() {
return tipo;
}
|
a3cd7b2e-c350-4d0b-ae85-bfb03eb4b14c
|
public void setTipo(Tipo tipo) {
this.tipo = tipo;
}
|
dc852f97-1e20-4e94-b2a5-d06be5dbfe0d
|
@Override
public String toString() {
return this.nome + " - " + this.descricao;
}
|
ee33c10e-bd27-4bda-94fe-df9965edb969
|
@XmlElement(name="cerveja")
public List<Cerveja> getCervejas() {
return cervejas;
}
|
71c1609b-e2e4-459a-abdf-9965d6e34c84
|
public void setCervejas(List<Cerveja> cervejas) {
this.cervejas = cervejas;
}
|
dc3ce583-0745-4f72-bf0a-dfd030b6b812
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String acceptHeader = request.getHeader("Accept");
if(acceptHeader == null || acceptHeader.contains("application/xml")){
escreveXML(request, response);
}else if(acceptHeader.contains("application/json")){
escreveJSON(request, response);
}else{
response.sendError(415); // formato nao suportado
}
}
|
4cc0272c-1a3e-47fb-b128-a7f3078373f7
|
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
try {
String identificador = null;
try {
identificador = obtemIdentificador(req);
} catch (RecursoSemIdentificadorException e) {
resp.sendError(400, e.getMessage());
}
if(identificador != null && estoque.recuperarCervejaPeloNome(identificador) != null){
resp.sendError(409, "Ja existe uma cerveja com esse nome");
return;
}
String tipoDeConteudo = req.getContentType();
Cerveja cerveja = null;
Unmarshaller unmarshaller = context.createUnmarshaller();
if(tipoDeConteudo == null || tipoDeConteudo.contains("application/xml")){
cerveja = (Cerveja) unmarshaller.unmarshal(req.getInputStream());
cerveja.setNome(identificador);
estoque.adicionarCerveja(cerveja);
String requestURI = req.getRequestURI();
resp.setHeader("Location", requestURI);
resp.setStatus(201);
escreveXML(req, resp);
}else if(tipoDeConteudo.contains("application/json")){
List<String> lines = IOUtils.readLines(req.getInputStream());
StringBuilder builder = new StringBuilder();
for (String line : lines) {
builder.append(line);
}
MappedNamespaceConvention con = new MappedNamespaceConvention();
JSONObject jsonObject = new JSONObject(builder.toString());
XMLStreamReader xmlStreamReader = new MappedXMLStreamReader(jsonObject, con);
cerveja = (Cerveja) unmarshaller.unmarshal(xmlStreamReader);
cerveja.setNome(identificador);
estoque.adicionarCerveja(cerveja);
String requestURI = req.getRequestURI();
resp.setHeader("Location", requestURI);
resp.setStatus(201);
escreveJSON(req, resp);
}else{
resp.sendError(415);
return;
}
} catch (Exception e) {
resp.sendError(500, e.getMessage());
}
}
|
89610b8d-9413-4a1b-9281-629aba044d49
|
private void escreveXML(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Object obj = localizaObjetoASerEnviado(request);
if(obj == null){
// objeto nao encontrado
response.sendError(404);
//return;
}else{
try {
Marshaller marshaller = context.createMarshaller();
response.setContentType("application/xml;charset=UTF-8");
marshaller.marshal(obj, response.getWriter());
} catch (JAXBException e) {
response.sendError(500, e.getMessage());
}
}
}
|
72c4aa4f-53b3-4201-9257-3d05069920d5
|
private void escreveJSON(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Object obj = localizaObjetoASerEnviado(request);
if(obj == null){
// objeto nao encontrado
response.sendError(404);
//return;
}else{
try {
response.setContentType("application/json;charset=UTF-8");
MappedNamespaceConvention con = new MappedNamespaceConvention();
XMLStreamWriter xmlStreamWriter = new MappedXMLStreamWriter(con, response.getWriter());
Marshaller marshaller = context.createMarshaller();
marshaller.marshal(obj, xmlStreamWriter);
} catch (JAXBException e) {
response.sendError(500, e.getMessage());
}
}
}
|
0bd1bbb6-b6e0-473b-a8cd-893dc3449cc9
|
private String obtemIdentificador(HttpServletRequest req) throws RecursoSemIdentificadorException{
String requestURI = req.getRequestURI();
String[] pedacosDaUri = requestURI.split("/");
boolean contextoCervejasEncontrado = false;
for(String contexto : pedacosDaUri){
if(contexto.equals("cervejas")){
contextoCervejasEncontrado = true;
continue;
}
if(contextoCervejasEncontrado){
try{
return URLDecoder.decode(contexto, "UTF-8");
}catch(UnsupportedEncodingException e){
return URLDecoder.decode(contexto);
}
}
}
throw new RecursoSemIdentificadorException("Recurso sem identificador");
}
|
d89e3e86-9c08-489c-b4af-4b5ecb4ded58
|
private Object localizaObjetoASerEnviado(HttpServletRequest req){
Object obj = null;
try {
String identificador = obtemIdentificador(req);
obj = estoque.recuperarCervejaPeloNome(identificador);
} catch (RecursoSemIdentificadorException e) {
Cervejas cervejas = new Cervejas();
cervejas.setCervejas(new ArrayList<Cerveja>(estoque.listarCervejas()));
obj = cervejas;
}
return obj;
}
|
82023adc-f78e-47e4-a9e9-7b3d57670644
|
public RecursoSemIdentificadorException(String message) {
super(message);
}
|
1f021d7d-a37b-4bc1-a8f6-5701df35676a
|
public Coin(double _x, double _y) {
x = _x;
y = _y;
yspeed = 3 + Math.random()*12;
xspeed = (Math.random()*2-1)*5;
}
|
a38f8383-1228-4583-b89d-aa66462e5c09
|
public void logic() {
x+=xspeed;
y+=yspeed;
yspeed -= 0.4;
}
|
0d7fd1c9-1049-445b-91cb-dbd6458a3900
|
public void draw() {
logic();
glPushMatrix();
glTranslated(x, y, 0);
glColor3d(1, 1, 0);
glBegin(GL_QUADS);
glVertex2d(-4, 0);
glVertex2d(4, 0);
glVertex2d(4, 8);
glVertex2d(-4, 8);
glEnd();
glPopMatrix();
}
|
a0fc32ed-6866-44ba-a931-3aa365c5ff8c
|
public void init() {
try {
wavEffect = AudioLoader.getAudio("WAV", ResourceLoader.getResourceAsStream("res/death.wav"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
|
8f76ed6f-b89e-4930-8a2b-31757ef17679
|
public Player() {
x = 100;
y = 100;
xspeed = 1;
dead = false;
}
|
c99a81ca-a6b1-41a7-bb87-3da115384ddd
|
public void logic() {
x += xspeed;
y += yspeed;
yspeed -= 0.4;
if (dead) {
if (y < -800)
dead = false;
return;
}
if (y <= 32) { // if on floor
yspeed = 0;
y = 32;
jumpsRemaining = 2;
if (!Keyboard.isKeyDown(Keyboard.KEY_LEFT) && xspeed < 0)
xspeed = xspeed * 0.9;
if (!Keyboard.isKeyDown(Keyboard.KEY_RIGHT) && xspeed > 0)
xspeed = xspeed * 0.9;
}
// check if player is too far outside borders
if (x >= 660) {
x = 5;
}
if (x <= -10) {
x = 645;
}
// teleport for the lulz
if (Keyboard.isKeyDown(Keyboard.KEY_T)) {
x = Math.random()*640;
y = Math.random()*480;
}
// Kill command! teleport to right above enemy
if (Keyboard.isKeyDown(Keyboard.KEY_K) && Game.killCommand == 1) {
Game.killCommand = 0;
x = Enemy.x + 3;
y = Enemy.y + 17;
}
if (jumpPressed && !jumpWasPressed && jumpsRemaining-- > 0)
yspeed = 7;
if (Keyboard.isKeyDown(Keyboard.KEY_LEFT))
xspeed = Math.max(-5, xspeed - 1);
if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT))
xspeed = Math.min(5, xspeed + 1);
jumpWasPressed = jumpPressed;
jumpPressed = Keyboard.isKeyDown(Keyboard.KEY_UP);
// check collision with enemy
if (Math.abs(x - Game.enemy.x) > 16 || Math.abs(y - Game.enemy.y) > 16)
return;
// if were here, then we the player is colliding with the enemy
if (yspeed < 0)
Game.enemy.kill();
else
kill();
}
|
a41f8ffb-056c-42eb-8e81-4e182b69bfff
|
public void kill() {
dead = true;
yspeed = 12;
deaths++;
init();
if (dead) {
wavEffect.playAsSoundEffect(1.3f, 0.04f, false);
}
}
|
003a22cc-138e-4a77-8fc8-9a08f0f69b51
|
public void draw() {
logic();
glPushMatrix();
glTranslated(x, y, 0);
glBegin(GL_QUADS);
glColor3d(1, 0, 0);
glVertex2d(-8, 0);
glColor3d(0, 1, 0);
glVertex2d(8, 0);
glColor3d(0, 0, 1);
glVertex2d(8, 16);
glColor3d(1, 1, 0);
glVertex2d(-8, 16);
glEnd();
glPopMatrix();
}
|
edbed323-22bf-4dba-9d41-dbb2cb800e5b
|
public static void Show() {
if (Keyboard.isKeyDown(Keyboard.KEY_H)) {
glBegin(GL_QUADS);
glColor3d(0.7, 0.8, 0.9);
glVertex2d(0, 0);
glVertex2d(640, 0);
glColor3d(0.5, 0.6, 0.8);
glVertex2d(640, 480);
glVertex2d(0, 480);
glEnd();
}
}
|
8fa464f2-612b-4644-a51a-8980f9f23e09
|
public static void main(String[] args) {
Game game = new Game();
game.start();
}
|
d3e00d85-a77b-4aed-8d98-0f693718ee9a
|
public void initSong() {
try {
song = AudioLoader.getAudio("WAV", ResourceLoader.getResourceAsStream("res/song.wav"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
|
f5636c47-bed5-417c-b632-908f325be353
|
public void start(){
try {
Display.setDisplayMode(new DisplayMode(640, 480));
Display.create();
Display.setTitle("Boxio");
} catch (LWJGLException e) {
e.printStackTrace();
}
initSong();
glEnable(GL_TEXTURE_2D);
player = new Player();
enemy = new Enemy();
coinList = new ArrayList<Coin>(0);
song.playAsMusic(1.0f, 0.05f, true);
while (!Display.isCloseRequested()) {
setCamera();
drawBackground();
player.draw();
enemy.draw();
for (Coin c : coinList)
c.draw();
DrawString.drawString("Deaths " + Player.deaths + "\n" + "Kills " + Enemy.kills + "\n" + "Press T to teleport random" + "\n" + "Press K to kill once per round" + "\n" + "Get 10 kills to win!", 320, 360);
End.end();
HighScore.Show();
Display.update();
Display.sync(60);
}
Display.destroy();
AL.destroy();
}
|
4bbe562c-de34-4003-998d-816c12c9facc
|
public static void setCamera() {
glEnable(GL_TEXTURE_2D);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
// alpha blending
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glViewport(0, 0, 640, 480);
glMatrixMode(GL_MODELVIEW);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 640, 0, 480, 1, -1);
glMatrixMode(GL_MODELVIEW);
}
|
956ff001-0d64-4b14-8ea1-de960962b70b
|
public static void drawBackground() {
// sky
glBegin(GL_QUADS);
glColor3d(0.7, 0.8, 0.9);
glVertex2d(0, 0);
glVertex2d(640, 0);
glColor3d(0.5, 0.6, 0.8);
glVertex2d(640, 480);
glVertex2d(0, 480);
glEnd();
// ground
glBegin(GL_QUADS);
glColor3d(0.5, 0.2, 0.1);
glVertex2d(0, 0);
glVertex2d(640, 0);
glVertex2d(640, 32);
glVertex2d(0, 32);
glEnd();
// grass
glBegin(GL_QUADS);
glColor3d(0.2, 0.8, 0.2);
glVertex2d(0, 25);
glVertex2d(640, 25);
glVertex2d(640, 32);
glVertex2d(0, 32);
glEnd();
}
|
2d4d9a91-a17d-464a-91dd-1dee4c538c71
|
public void init() {
try {
wavEffect = AudioLoader.getAudio("WAV", ResourceLoader.getResourceAsStream("res/kill.wav"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
|
4ca247a5-cf7e-4594-ada4-0b7555457e43
|
public Enemy() {
x = 200;
y = 32;
}
|
a3a6df90-b7d7-4c4f-8e8d-68d9bf297e38
|
public void logic() {
x += 1;
if (x > 640 + 10)
x = -10;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.