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

Printable Version | Subscribe | Add to Favorites  
 Pages:  1  2  3
Author: Subject: Pomoc oko JAVA programiranja!
master_yoda
on probation
******

Avatar


Posts: 3646
Registered: 23.12.2004
Member Is Offline


[*] posted on 15.6.2011 at 10:50


Code:
class Novcici
{
public int x; //x i y koordinate za novcice.
public int y;
Image novcicSlika;

public Novcici()
{
mojiNovcici[i].novcicSlika = getImage(getCodeBase(), "novcic.gif");

}


To daje error, negde drugde treba da premestim?

Obrisao sam to drugo pozivanje iscrtavanja slike a enumeraciju nisam bio uspeo da namestim...




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 11:16


Quote: Originally posted by master_yoda  
Code:
class Novcici
{
public int x; //x i y koordinate za novcice.
public int y;
Image novcicSlika;

public Novcici()
{
mojiNovcici[i].novcicSlika = getImage(getCodeBase(), "novcic.gif");

}


To daje error, negde drugde treba da premestim?

Obrisao sam to drugo pozivanje iscrtavanja slike a enumeraciju nisam bio uspeo da namestim...


Probaj ovako:
Code:
class Novcici
{
public int x; //x i y koordinate za novcice.
public int y;
Image novcicSlika;

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

}


Pokusaj jos jednom enumeraciju. ne bi trebalo da bude tesko. Bukvalno ce ti sve ostati skoro isto samo ces imati npr. Pravac.stop umesto "stop". i promenljiva pravac ce ti biti tipa Pravac, a ne tipa string.

edit: i nemoj odma odustajati ako ti izbacuje gresku. Nije to kraj sveta :D Eclipse je veoma pametno okruzenje i prilicno je lako resiti vecinu problema, a i tako ces najbolje nauciti.

[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
master_yoda
on probation
******

Avatar


Posts: 3646
Registered: 23.12.2004
Member Is Offline


[*] posted on 15.6.2011 at 11:23


Opet error i tako, ponudjeno resenje je:

Code:
private Image getImage(Object codeBase, String string) {
return null;
}

private Object getCodeBase() {
return null;
}


Da ostavim sa tim? Onda je bez errora.

Nakon sto sam to uradio ne prikazuje vise slike. :/

[Edited on 15.6.2011 by master_yoda]




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 11:31


ne ne :D

Code:

class Novcici
{
public int x; //x i y koordinate za novcice.
public int y;
Image novcicSlika;
Applet owner;

public Novcici(Applet owner)
{
this.owner = owner;
novcicSlika = owner.getImage(owner.getCodeBase(), "novcic.gif");
}

public void newNovcici(Random g1) //Funkcija za generisanje novog novcica.
{
...
}

public void pomeriNovcic(int y1, Random g1) //Funkcija za pomeranje novcica.
{
...
}
}

ovako ga kreiras u Avioni klasi:

mojiNovcici[i] = new Novcici(this);

a ovo izbaci:

mojiNovcici[i].novcicSlika = getImage(getCodeBase(), "novcic.gif");


getImage i getCodeBase su metode iz apleta i zato nisi mogao da im pristupis. Zato moras da dodas referencu na aplet u klasu Novcic da bi mogao da ih pozoves. A onda pri pozivu konsturktora prosledis "this" sto je ustvari referenca na sam aplet Avioni.

[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
master_yoda
on probation
******

Avatar


Posts: 3646
Registered: 23.12.2004
Member Is Offline


[*] posted on 15.6.2011 at 11:45


Radi sad, poslacu veceras profesoru pa se nadam da ce biti zadovoljan sa ovom verzijom. :)

Hvala puno!




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 11:52


Ma nema na cemu :)
Ako ne uspes da odradis enumeraciju onda bar stavi neke int konstante umesto stringova.





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 17.6.2011 at 06:49


Quote:
I dalje ima jako mnogo treperenja. Ne znam kako ste implementirali dvostruko baferisanje (nisam analizirao kod),
ali uzasno treperi. Pa, valjda je tako i kod Vas? Molim Vas, popravite to ponovo.


Pa sta vise da radim? :(




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 17.6.2011 at 08:21


Hm, jesi zamenio stringove sa necim drugim? Sad ces morati da rasteretis onaj paint maksimalno. Probaj i da smanjis dimenzije apleta pa samim tim i broj aviona i novcica. Mada mi nije jasno kako njemu treperi.



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 17.6.2011 at 09:24


Nisam ozbiljnije menjao nista da ne bi promena u jednoj klasi sve pokvarila. :/

Izgooglao sam ovo:

http://www.javacooperation.gmxhome.de/BildschirmflackernEng.html

I odatle iskopirao ovo:

Quote:
Double buffering: the code

// declare two instance variables at the head of the program
private Image dbImage;
private Graphics dbg;

... other code ...

/** Update - Method, implements double buffering */
public void update (Graphics g)
{
// initialize buffer
if (dbImage == null)
{
dbImage = createImage (this.getSize().width, this.getSize().height);
dbg = dbImage.getGraphics ();
}

// clear screen in background
dbg.setColor (getBackground ());
dbg.fillRect (0, 0, this.getSize().width, this.getSize().height);

// draw elements in background
dbg.setColor (getForeground());
paint (dbg);

// draw image on the screen
g.drawImage (dbImage, 0, 0, this);
}
As I said before you can copy and paste this code into every applet that uses animations!


Mozda to resava problem? Meni i dalje izgleda isto, ali dok sam pokusavao da namestim sam izazvao neko treperenje tako da pretpostavljam da njemu tako izgleda, samo mi nije jasno zasto. :(




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 17.6.2011 at 09:32


To ti je opet isto kao i ono sto si ti uradio. Ja ne vidim nikakv problem sa tvojom implementacijom double buffering-a.
Kao sto sam ti ranije rekao prva stvar koja mi upada u oci je ono poredjenje stringova koga ima stvarno dosta, a sigurno ti trosi dosta resursa.




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 17.6.2011 at 09:46


Onda ako ti nije problem napisi mi jedno nubovsko uputstvo sta tacno treba da zamenim...



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 17.6.2011 at 10:10


Code:

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

umesto :
private String pravac = "start1";
imaces:
private Pravac pravac = Pravac.start1; // umesto stringa pravac imao bi ovo
umesto:
private String tempPravac = "";
private Pravac tempPravac;
...
kod dodele imaces umesto:
pravac = "dole";
imaces:
pravac = Pravac.dole;

i tako na svakom mestu gde imas dodelu vrednosti pravcu i tempPravcu



dole kod poredjenja
umesto:
if(pravac1.equals("izlaz"))

imaces:

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

ovo izmenis svuda gde imas poredjene




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 17.6.2011 at 13:05


Izmenjao sam pravac i kod poredjenja, da li da isto uradim i sa public string pticePravac?



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 17.6.2011 at 13:51


mozes nece da skodi.
Jesi i za ptice i ostale avione stavio da se slika ucitava u konstruktoru?




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 17.6.2011 at 14:12


Jesam. Da li ima jos nesto sto mogu da uradim da mu ne bi treperilo? :/



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 17.6.2011 at 14:30


Pa nemam pojam. Aj okaci najnoviju verziju.



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 17.6.2011 at 14:41


Nisam stigao da promenim za pticePravac a sad zurim na kolokvijum, okacicu veceras.



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 17.6.2011 at 14:47


Evo na sta sad lici:

https://rapidshare.com/files/4105134866/javaVerzija3.rar




View user's profile View All Posts By User
DragonOfTheEarth
One of the Seven Angels
******

Avatar


Posts: 1849
Registered: 30.6.2006
Location: Highway To Hell
Member Is Offline

Mood: Uncanny X-men

[*] posted on 17.6.2011 at 17:44


Kod mene ovo nece ni da se pokrene, lol.

Tacnije, mogu da pokrenem, ali samo dodjem do dela koji kaze "Zvuk ukljucen" i onda se freezuje.

[Edited on 17.6.2011 by DragonOfTheEarth]




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 17.6.2011 at 18:32


Extractujes folder, otvoris html fajl, ukljucis Num Lock i pritisnes 8, probao sam i na drugom kompu, radi.



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 18.6.2011 at 16:32


Gledam sad profesorov primer kako implementirati double buffering, jedino sto se razlikuje je:

Code:

public void paint (Graphics g) {

// 3. korak
drugiEkranG.setColor(Color.black);
drugiEkranG.fillRect(0,0,100,100);
drugiEkranG.setColor(Color.white);
drugiEkranG.fillRect(101,0,100,100);
drugiEkranG.setColor(Color.red);
drugiEkranG.fillOval(xpos, 5,90,90);

// 4. korak
g.drawImage(drugiEkranSlika,0,0,this);
}



Kod mene je:

Code:

public void paint(Graphics g)
{
vanGrafike.setColor(getBackground());
vanGrafike.fillRect(0, 0, 500, 500); //Puni vanSlike sa belom pozadinom.
vanGrafike.setColor(Color.black);

paintFrame(vanGrafike); //Funkcija koja crta sve u vanGrafike.
g.drawImage(vanSlike, 0, 0, [b]null[/b]); //Crta vanSlike na glavni ekran.
}


Promenio sam null u this, sta se time menja?




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 18.6.2011 at 17:41


Zadnji parametar funkcije ti je imageObserver to jest objekat koji ce biti obavesten o statusu iscrtavanja slike.
I u onom primeru koji sam ti okacio bilo je this, samo sto ni ja nisam primetio. Ne znam koliko ce to uticaja imati na iscrtavanje, al ostavi this.

http://download.oracle.com/javase/1.4.2/docs/api/java/awt/Graphics....




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 18.6.2011 at 17:49


Pa da, ostavicu this. Reci cu mu da pogleda kod posto sam odradio double buffering kao u njegovom primeru i zamenio stringove za Pravac sa enumeracijom jer to trosi manje resursa... Jel ostalo jos nesto sto bi moglo da utice na to treperenje koje on ima ili da saljem ovo?



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 21.6.2011 at 20:16


Cisto da spomenem kako se ovo zavrsilo...

Quote:
Bas ste me namucili sa Vasim projektom. Pogledao sam i na drugom racunaru i tu
zaista ne treperi, ali tu nemam numericku tastaturu pa sam morao d akoristim i 3. racunar. Program nije bas pltaformski nezavisan. Dobili ste 7 bodova.


Umesto da mi je rekao da mu to smeta odmah kada sam mu poslao prvu verziju pre vise od nedelju dana (zbog cega sam mu i poslao ranije) sad mi kaze, srecan mi rodjendan. I pored toga kontrole rade na U, O, J, K i L ako korisnik nema numericku tastaturu (tako sam ja testirao jer imam lap top) pa sam mu to napisao, nadam se da ce da uvazi. Nije problem zbog tri poena nego stvarno sam se trudio da sredim ovo sto bolje, prvi put smo dobili da radimo ovako nesto i sad mi ovo napise...

[Edited on 21.6.2011 by master_yoda]




View user's profile View All Posts By User
DragonOfTheEarth
One of the Seven Angels
******

Avatar


Posts: 1849
Registered: 30.6.2006
Location: Highway To Hell
Member Is Offline

Mood: Uncanny X-men

[*] posted on 21.6.2011 at 21:48


Lik je jednostavno debil. Ja sam mu rad poslao prvi put jos pretproslog cetvrtka, i odgovorio mi je tek kad sam mu poslao ponovo mail. I to mi je rekao da mu se ne svidja i da treba da dodam jos stvari. Zbog analize i diskretne sam uradio tek u subotu, i poslao mu, ali mi jos kreten nije odgovorio...



View user's profile View All Posts By User This user has MSN Messenger
 Pages:  1  2  3

  Go To Top

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