Emulation Galaxy Forums
Not logged in [Login ]
Go To Bottom

Printable Version | Subscribe | Add to Favorites  
 Pages:  1    3
Author: Subject: Pomoc oko JAVA programiranja!
gogos11
1337 Member
******

Avatar


Posts: 793
Registered: 26.8.2010
Member Is Offline


[*] posted on 25.5.2011 at 15:58
Pomoc oko JAVA programiranja!


OVAKO...

Potrebno mi da se urade ovi zadatci, ima ih 5, posto bas slabo poznajem javu, ne znam da uradim, pa bih molio nekog ako zna i da mu ne oduzima mnogo vremena, da mi uradi ih, ne sve nego koliko moze...

Uplaodovao sam u zippu ove zadatke....


http://www34.zippyshare.com/v/31017465/file.html

ZAHVALAN SAMM VAM NA BILO KAKVOJ POMOCI !!!! :D






View user's profile View All Posts By User
meca dobric
*tatina devojcica*
******

Avatar


Posts: 2986
Registered: 9.8.2002
Location: Novi Sad
Member Is Offline

Mood: woohoo

[*] posted on 25.5.2011 at 16:10


Sve sto ti je potrebno mozes naci ovde: Free Electronic Book: Thinking in Java, 3rd Edition
View user's profile Visit user's homepage View All Posts By User This user has MSN Messenger
Stale
Fr1ck
******

Avatar


Posts: 2066
Registered: 29.9.2006
Location: Novi Sad
Member Is Offline

Mood: Winter Is Coming

[*] posted on 25.5.2011 at 16:10


Quote: Originally posted by gogos11  
OVAKO...
...posto bas slabo poznajem javu...


a ima li bolje prilike da je naucis nego radeci ove zadatke?!?




I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I've watched C-beams glitter in the dark near the Tannhauser Gate. All those moments will be lost in time, like tears in the rain. Time to die.


To permit irresponsible authority is to sow disaster; to hold a man responsible for anything he does not control is to behave with blind idiocy.

View user's profile Visit user's homepage View All Posts By User
gogos11
1337 Member
******

Avatar


Posts: 793
Registered: 26.8.2010
Member Is Offline


[*] posted on 25.5.2011 at 16:45


Nemam bas sad vremena da ucim javu, u skripcu sam sa vremenom, pa sam zato trazio pomoc da mi neko uradi ove zadate, odnosno neke od ovih, kako bi mogao predati na vrijeme!




View user's profile View All Posts By User
Maxa
the Unyielding
*******

Avatar


Posts: 12591
Registered: 8.2.2004
Location: dunno...
Member Is Offline

Mood: fuckit...

[*] posted on 26.5.2011 at 07:45


a što nisi učio na vreme? :P



My friends call me Hadoken because I'm down-right fierce!
A man's home is where his heart is, in my case... the penis! - Danny Crane
What the fuck did I do?! - Jimmy McNulty
Please stop putting unattractive women that you jerk off to in your signatures. We don't care!
Also, meaningless gifs are meaningless.
View user's profile Visit user's homepage View All Posts By User This user has MSN Messenger
forsaken demon
Supper Administrator
*********

Avatar


Posts: 13499
Registered: 9.8.2002
Location: Novi Sad
Member Is Offline

Mood: What a horrible life to have a curse

[*] posted on 26.5.2011 at 08:59


Mislio sam da smo se dogovorili da se ne prave ovakvi topic, nismo stvarno forum za domaće zadatke... U krajnjem slučaju vidite i kako ljudi reaguju.





'Fighting evil, so you don't have to!'

"What are you dense? Are you RETARDED or something? Who the hell do you THINK I am?
I'm the goddamn Batman." - Batman Ultimate thread
View user's profile Visit user's homepage View All Posts By User
Stale
Fr1ck
******

Avatar


Posts: 2066
Registered: 29.9.2006
Location: Novi Sad
Member Is Offline

Mood: Winter Is Coming

[*] posted on 26.5.2011 at 09:29


Ma nije problem u trazenu pomoci, da je postavio konkretno pitanje ja bi mu prvi pomogao :)



I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I've watched C-beams glitter in the dark near the Tannhauser Gate. All those moments will be lost in time, like tears in the rain. Time to die.


To permit irresponsible authority is to sow disaster; to hold a man responsible for anything he does not control is to behave with blind idiocy.

View user's profile Visit user's homepage View All Posts By User
Darth Revan
Fr1ck
******

Avatar


Posts: 2323
Registered: 9.10.2004
Location: Beograd
Member Is Offline

Mood: Optimist

[*] posted on 26.5.2011 at 12:38


I ja isto, potpuno je ok ako se nesto ne razumije, ili nesto skripi tu sam da pomognem.

Sto se tice radjena domacih zadataka vecina javaforuma (dreamincode, javaranch) ima praksu da automatski zatvara ovakve topice.




\"You remind me of myself...before I was slaughtered and cast into the Abyss.\"

\"A shame the manner of this man\'s death prevents us from restoring him to life - my interrogations could have brought us much information!\"

\"I will be the last! And you will go first... Heh hehehehe...\"
View user's profile View All Posts By User
Nick
Super Administrator
*********

Avatar


Posts: 30509
Registered: 30.7.2002
Location: New Belgrade, SERBIA
Member Is Offline

Mood: CHANGE!

[*] posted on 26.5.2011 at 17:24


Meni treba neko ko ima najosnovnija znanja o Javi da mi objasni neke really basic gluposti, cimajte na u2u.





You don't stop playing video games because you get old. You get old because you stop playing video games. :)
View user's profile Visit user's homepage View All Posts By User This user has MSN Messenger
Darth Revan
Fr1ck
******

Avatar


Posts: 2323
Registered: 9.10.2004
Location: Beograd
Member Is Offline

Mood: Optimist

[*] posted on 26.5.2011 at 18:37


Mozes i odje, a mozes i da mi posaljes na u2u sta nije jasno.



\"You remind me of myself...before I was slaughtered and cast into the Abyss.\"

\"A shame the manner of this man\'s death prevents us from restoring him to life - my interrogations could have brought us much information!\"

\"I will be the last! And you will go first... Heh hehehehe...\"
View user's profile View All Posts By User
master_yoda
on probation
******

Avatar


Posts: 3646
Registered: 23.12.2004
Member Is Offline


[*] posted on 13.6.2011 at 15:44


OK, imam jedno konkretno pitanje.

Dobili smo zadatak da preradimo/prevedemo igru sa interneta u Javi. Evo sta sam uradio:

https://rapidshare.com/files/3160396239/javaProjekat.rar

Na to sam dobio odgovor od profesora da je "treperenje tako uzasno da program ne moze da se koristi" i da pogledam primer sa poslednjeg casa i to primenim.

Taj primer:

https://rapidshare.com/files/3624387157/tocak.rar

Prvi tocak navodno treperi a kod drugog je to ispravljeno, mada ja ne vidim razliku osim u boji. Isto to iz Tocka2 i ja treba da primenim ali mi ne ide, da li neko moze da pomogne? Pretpostavljam da ne treba da menjam nista u postojecem kodu vec samo treba dodati sledeca 4 koraka koja se vide u kodu za tocak2:

1. Najpre se deklarišu 2 promenljive ( na primer: drugiEkranSlika i drugiEkrang).
2. Zatim se kreiraju ova 2 objekta tako da budu jednaki veličini prozora apleta.
3. Kad god treba da crtamo nešto, crtamo na drugom ekranu.
4. Na kraju prikažemo sliku u paint-metodu (kao i druge slike).




View user's profile View All Posts By User
Stale
Fr1ck
******

Avatar


Posts: 2066
Registered: 29.9.2006
Location: Novi Sad
Member Is Offline

Mood: Winter Is Coming

[*] posted on 13.6.2011 at 16:07


Mislim da je profa hteo da odradis double buffering. Tvoj primer iz nekog razloga kod mene ne iscrtava nista.
primer: http://www.realapplets.com/tutorial/DoubleBuffering.html




I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I've watched C-beams glitter in the dark near the Tannhauser Gate. All those moments will be lost in time, like tears in the rain. Time to die.


To permit irresponsible authority is to sow disaster; to hold a man responsible for anything he does not control is to behave with blind idiocy.

View user's profile Visit user's homepage View All Posts By User
master_yoda
on probation
******

Avatar


Posts: 3646
Registered: 23.12.2004
Member Is Offline


[*] posted on 13.6.2011 at 16:16


Da, to treba da primenim. Ne znam sto ti ne prikazuje, evo koda:

http://pastebin.com/WvmGGKNK

[Edited on 14.6.2011 by master_yoda]




View user's profile View All Posts By User
meca dobric
*tatina devojcica*
******

Avatar


Posts: 2986
Registered: 9.8.2002
Location: Novi Sad
Member Is Offline

Mood: woohoo

[*] posted on 14.6.2011 at 08:01


Quote: Originally posted by master_yoda  
Da, to treba da primenim. Ne znam sto ti ne prikazuje, evo koda:


Code:
ceo kod


Sjajan post!

Preporuka za http://pastebin.com/ za ovakve copy/paste poruke.

edit:sklonjen kod na pastebin :)

[Edited on 14-6-2011 by meca dobric]
View user's profile Visit user's homepage View All Posts By User This user has MSN Messenger
Rocky
Capcom sUiCidE
*******

Avatar


Posts: 4658
Registered: 24.4.2003
Location: Zemun
Member Is Offline

Mood: zabadač noževa u leđa

[*] posted on 14.6.2011 at 08:33


Možda bi mogao da razmisliš da razdvojiš funkcionalnosti u par klasa... ali da ne davimo sa onim što nije tema.



~=~Rocky~=~




View user's profile View All Posts By User This user has MSN Messenger
master_yoda
on probation
******

Avatar


Posts: 3646
Registered: 23.12.2004
Member Is Offline


[*] posted on 14.6.2011 at 09:07


Quote: Originally posted by meca dobric  

Sjajan post!

Preporuka za http://pastebin.com/ za ovakve copy/paste poruke.


OK promenio sam, nisam znao za to.

Quote: Originally posted by Rocky  
Možda bi mogao da razmisliš da razdvojiš funkcionalnosti u par klasa... ali da ne davimo sa onim što nije tema.


Ima sest klasa (Avioni, Novcici, Oblaci itd.) samo sam ih sve prekopirao odjednom.

Jos samo da mi neko pomogne oko implementacije double bufferinga na ovaj primer jer sam ja nesto pokusavao i uspeo da kompajliram bez gresaka ali nista se nije promenilo...




View user's profile View All Posts By User
Stale
Fr1ck
******

Avatar


Posts: 2066
Registered: 29.9.2006
Location: Novi Sad
Member Is Offline

Mood: Winter Is Coming

[*] posted on 14.6.2011 at 09:37


U onom projektu ti fale sve slicice. Zato mi nista ne iscrtava. Aj okaci projekat sa svim resursima.

Trebao si da procitas komentare u onom primeru sto sam ti okacio
Code:

// Always required for good double-buffering.
// This will cause the applet not to first wipe off
// previous drawings but to immediately repaint.
// the wiping off also causes flickering.
// Update is called automatically when repaint() is called.

public void update(Graphics g)
{
paint(g);
}


Znaci u update-u stavi samo poziv paint(g);
inicijalizaciju vanSlike i vanGrafike prebaci u init.

ostatak iz update-a prebaci u paint metodu

provere if(vanGrafike == null) i if(vanGrafike != null) ti ne trebaju, jer si samu inicijalizaciju obavio u init-u.


OBAVEZNO:
Nemoj koristiti stringove da ti odredjuju pravac. To je jaaako neoptimizovano. Preporucujem ti da koristis enumeraciju.
Koristi switch case ili else if kod provere pravca. Jer ovo kako si sad odradio je da se svaki put porede svi moguci pravci sto je opet jako neoptimizovano, jer u delu koji ti radi iscrtavanje i treba da bude sto brzi ti radis X poredjenja stringova bespotrebno.
Slike preload-uj u init-u, jer ih ovako svaki put iznova ucitavas u memoriju.

Sredi prvo ovo pa vidi hoce li ti manje seckati.

[Edited on 14.6.2011 by Stale]

[Edited on 14.6.2011 by Stale]




I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I've watched C-beams glitter in the dark near the Tannhauser Gate. All those moments will be lost in time, like tears in the rain. Time to die.


To permit irresponsible authority is to sow disaster; to hold a man responsible for anything he does not control is to behave with blind idiocy.

View user's profile Visit user's homepage View All Posts By User
master_yoda
on probation
******

Avatar


Posts: 3646
Registered: 23.12.2004
Member Is Offline


[*] posted on 14.6.2011 at 12:20


Slike su u bin folderu, okacio sam ceo folder iz Eclipse workspace foldera, ne znam kako drugacije, zar nije to sve?

Nazalost kao sto rekoh ja sam samo uzeo gotovu igru sa interneta, promenio slike, zvukove, imena promenljivih i sve ih preveo na srpski, nemam dovoljno znanja da znam da primenim sve sto si naveo kao sto je optimizacija, ja sam srecan sto radi. :) U update sam stavio paint(g) a sve ostalo prebacio u paint.

Image vanSlike i Graphics vanGrafike (al sam preveo) ako prebacim u init a obrisem sa pocetka dobijam dosta errora. Nadao sam se da mogu da dodam samo par linija koda za double buffering i da to tako resim, ne bih umeo da sustinski izmenjam ceo kod...




View user's profile View All Posts By User
Stale
Fr1ck
******

Avatar


Posts: 2066
Registered: 29.9.2006
Location: Novi Sad
Member Is Offline

Mood: Winter Is Coming

[*] posted on 14.6.2011 at 12:56


Ti ovde vec imas double buffering. Samim tim sto iscrtavas sve na vanGrafike pa onda iscrtas samo to. Sad si ga samo malo dodatno sredio.

vanSlike i vanGrafike ostavi kao field-ove, ali ih inicijalizuj u initu.

Code:

//znaci gore

Image vanSlike; //Image and Graphics za crtanje van ekrana i kopiranje
Graphics vanGrafike;


//a u initu

vanSlike = createImage(500, 500);
vanGrafike = vanSlike.getGraphics();



Sto se tice enumeracije u javi http://download.oracle.com/javase/tutorial/java/javaOO/enum.html

ti bi imao:
Code:

public enum Pravac {
start1, usporenje, izlaz, gorelevo, goredesno // i tako nabrojis sve one stringove koje si koristio za pravac
}

private Pravac pravac = Pravac.start1; // umesto stringa pravac imao bi ovo

...

if(pravac1.equals(Pravac.izlaz)) // ovako bi ga poredio. Ovo ti je puno brze nego kad bi poredio stringove



sto se tice onih if- ova

Code:

if(pravac.equals("dolelevo")) //Avion se krece brzo dole i levo.
{
... neki kod
}

if(pravac.equals("doledesno")) //Avion se krece brzo dole i desno.
{
... neki kod

}

if(pravac.equals("dole")) //Avion se krece brzo dole i desno.
{
... neki kod

}


posto se svi ti if-ovi medjusobno iskljucuju tj ne moze u jednom prolazu kroz tu funkciju pravac biti razlicitih vrednosti

stavi npr ovako

Code:


if(pravac.equals("dolelevo")) //Avion se krece brzo dole i levo.
{
... neki kod
}
else if(pravac.equals("doledesno")) //Avion se krece brzo dole i desno.
{
... neki kod

}
else if(pravac.equals("dole")) //Avion se krece brzo dole i desno.
{
... neki kod

}


Time ces dobiti to da ne radis svaki put sva poredjenja nego samo dok ne dodjes do onog koje je trenutno stanje pravca.
Najbolje je da ti napocetku budu najcesci slucajevi, a oni redji nize u else if "lancu".


Slicice i ostale resurse bi trebao da drzis negde van bin-a, al ok, Posto ih meni eclipse izgleda obrisao pri buildu. Sad kad sam iskopirao radi ok. Kod mene ovo tvoje ne secka, al ne znam kakva je profina masina.

[Edited on 14.6.2011 by Stale]




I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I've watched C-beams glitter in the dark near the Tannhauser Gate. All those moments will be lost in time, like tears in the rain. Time to die.


To permit irresponsible authority is to sow disaster; to hold a man responsible for anything he does not control is to behave with blind idiocy.

View user's profile Visit user's homepage View All Posts By User
master_yoda
on probation
******

Avatar


Posts: 3646
Registered: 23.12.2004
Member Is Offline


[*] posted on 14.6.2011 at 13:23


OK izmenjao sam ovo ali ja i dalje ne vidim neku razliku nakon pokretanja igre u odnosu na ranije. Ja sam profesoru taj projekat poslao na mail i dobio odgovor da je "treperenje tako uzasno da program ne moze da se koristi" pa sam ocekivao da ceo ekran treperi ili nesto slicno ali isprobao sam na vise racunara/browsera i svuda radi isto a i ti si mi potvrdio... Jedino ako ne misli na to sto avioni, oblaci i novcici trepere pri brzom kretanju u odnosu na onog aviona kojim igrac upravlja, sto ne znam da li moze da se ispravi?



View user's profile View All Posts By User
Stale
Fr1ck
******

Avatar


Posts: 2066
Registered: 29.9.2006
Location: Novi Sad
Member Is Offline

Mood: Winter Is Coming

[*] posted on 14.6.2011 at 14:22


Pa nemam pojma ti njemu napomeni da si odradio double buffering i optimizovao kod pa ako se jos bude zalio, pokusaj da ga jos malo restruktuiras moze biti da pomogne.

Da li planiras da izmenis slicice tvog aviona? tj. da ti pri skretanju ucita drugu sliku. jer ako neces taj deo koda ti je nepotreban.




I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I've watched C-beams glitter in the dark near the Tannhauser Gate. All those moments will be lost in time, like tears in the rain. Time to die.


To permit irresponsible authority is to sow disaster; to hold a man responsible for anything he does not control is to behave with blind idiocy.

View user's profile Visit user's homepage View All Posts By User
master_yoda
on probation
******

Avatar


Posts: 3646
Registered: 23.12.2004
Member Is Offline


[*] posted on 14.6.2011 at 14:39


Znaci time sto je u updateu paint(g) a u paintu ono sto je bilo tamo sam ja ustvari odradio double buffering?

U original igri su bile razlicite slicice za levo i desno, ja nisam to radio vec sam stavljao istu sliku za sve, sta da izbacim onda? Nesto sam probao ali onda je umesto aviona bila prikazana eksplozija i nakon slupanja.




View user's profile View All Posts By User
Stale
Fr1ck
******

Avatar


Posts: 2066
Registered: 29.9.2006
Location: Novi Sad
Member Is Offline

Mood: Winter Is Coming

[*] posted on 14.6.2011 at 15:15


Znaci ovo iz paintFrame
Code:

if(pravac.equals("slupan")) //Stavlja druge slike za avion.
mojAvion = getImage(getCodeBase(), "eksplozija.gif");
if(pravac.equals("stop") || pravac.equals("gorelevo") || pravac.equals("goredesno"))
mojAvion = getImage(getCodeBase(), "avion1.gif");
if(pravac.equals("levo"))
mojAvion = getImage(getCodeBase(), "avion2.gif");
if(pravac.equals("desno"))
mojAvion = getImage(getCodeBase(), "avion3.gif");
if(pravac.equals("dolelevo"))
mojAvion = getImage(getCodeBase(), "avion4.gif");
if(pravac.equals("doledesno"))
mojAvion = getImage(getCodeBase(), "avion5.gif");
if(pravac.equals("dole"))
{
if(smer < 8) //Stavlja slike na osnovu smera.
mojAvion = getImage(getCodeBase(), "avion6.gif");
else
{
mojAvion = getImage(getCodeBase(), "avion7.gif");
if(smer >= 16)
smer = 0;
}
}


zameni sa ovim:

Code:

if(pravac.equals("slupan")) //Stavlja druge slike za avion.
mojAvion = getImage(getCodeBase(), "eksplozija.gif");
else
mojAvion = getImage(getCodeBase(), "avion1.gif");

if(smer >= 16) smer = 0;



i slobodno obrisi te slike koje su visak avion2-7.

Double buffering se odnosi na to da se ne iscrtava direktno u output buffer (u tvom slucaju ne crtas direktno po Graphics g objektu apleta) nego se prvo sve iscrtavanje odradi u offscreen bufferu koji se trenutno ne iscrtava pa se onda izvrsi zamena buffera (u tvom slucaju crtas na Graphics objektu vanSlike koji se zove vanGrafike i kada sve iscrtas na njemu vanSlike iscrtas na Graphics-u od apleta).
Nadam se da sam donekle razumljivo objasnio :)

[Edited on 14.6.2011 by Stale]




I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I've watched C-beams glitter in the dark near the Tannhauser Gate. All those moments will be lost in time, like tears in the rain. Time to die.


To permit irresponsible authority is to sow disaster; to hold a man responsible for anything he does not control is to behave with blind idiocy.

View user's profile Visit user's homepage View All Posts By User
master_yoda
on probation
******

Avatar


Posts: 3646
Registered: 23.12.2004
Member Is Offline


[*] posted on 14.6.2011 at 15:48


Uspeo sam i to da promenim, sada nemam te avione viska. :) I mislim da sam te razumeo po kom principu radi double baffering.

Evo ga izmenjeni kod:

https://rapidshare.com/files/3015066382/javaProjekat2.rar

Valjda je to-to sad? I dalje trepere ovi ostali avioni, ptice i oblaci ali to valjda tako mora?

E da, PUNO ti hvala na pomoci. :)




View user's profile View All Posts By User
Stale
Fr1ck
******

Avatar


Posts: 2066
Registered: 29.9.2006
Location: Novi Sad
Member Is Offline

Mood: Winter Is Coming

[*] posted on 15.6.2011 at 10:28


inicijalizaciju slicica za novcic, oblak i ostalo prebaci u konstruktor od tih klasa. jedino mozda pticu ostavi tu posto njoj menjas slicicu, al i to ti je bolje da napravis tako da u klasi Ptica imas dva Image objekta koja loadujes pri kreiranju same ptice. Pa tamo kad poredis pravac ptice samo pozoves iscrtavanje druge slike.

znaci ovo:
Code:

novcicSlika = getImage(getCodeBase(), "novcic.gif");

prebaci u konstruktor od novcica. i tako isto za ostale.

Paint deo mora da ti bude sto rastereceniji, jer ako tu imas previse racunanja, ucitavanja i ostalih cuda seckace ti slika. Primetio si da u vecina igara ima loading deo gde kreiraju vecinu objekata, ucitavaju texture, sprajtove... i ostalo sto ce kasnije iscrtavati, jer je "skupo" da se to radi u toku iscrtavanja.

ovo izbaci skroz, jer ovako 2x pozivas iscrtavanje vanSlike:

Code:

if (vanSlike != null) //Pravi vanSlike ako ne postoji.
{
g.drawImage(vanSlike, 0, 0, null);
}

if(vanGrafike == null)
{
vanSlike = createImage(500, 500);
vanGrafike = vanSlike.getGraphics();
}


Jos uvek nisi odradio pravac kao enumeraciju sto bi trebao da uradis, jer imas dosta poredjenja.



[Edited on 15.6.2011 by Stale]




I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I've watched C-beams glitter in the dark near the Tannhauser Gate. All those moments will be lost in time, like tears in the rain. Time to die.


To permit irresponsible authority is to sow disaster; to hold a man responsible for anything he does not control is to behave with blind idiocy.

View user's profile Visit user's homepage View All Posts By User
 Pages:  1    3

  Go To Top

Powered by XMB 1.9.11
Developed By The XMB Group © 2001-2010