Benvenuto Visitatore(Log In|Registrati)
![]() ![]() |
8 Feb 2015, 20:42
Messaggio
#1
|
|
Gruppo: Gamer Messaggi: 42 Iscritto il: 3 February 15 Da: Lecce, Italy Utente Nr.: 20.669 BGE Psychic detective Playing Phantasmagoria SO Windows7 |
Ciao Ragazzi,
Sono nuovo nel forum è vorrei poter chiedere un opinione riguardo un problema che sto avendo.. Cerco in tempo reale di disegnare un orologio sulla mia room tramite il comando DrawLines. Va tutto alla grande tranne il fatto che quando cerco di inizializzare il disegno il gioco interno incomincia ad andare a rilento... Come se si stesse sforzando tantissimo a fare questa operazione... La eseguo tramite repeatedly_execute_always() Dato che dovrebbe disegnare le linee ad ogni frame al secondo... Qualcuno potrebbe darmi una mano ? Grazie in anticipo ragazzi. CODICE DynamicSprite*backgroundCopy;
function DrawClock(this Object*, int centrex, int centrey, int radius) { DrawingSurface *ds = Room.GetDrawingSurfaceForBackground(); backgroundCopy = DynamicSprite.CreateFromBackground(0); ds.Clear(); ds.DrawImage(0, 0, backgroundCopy.Graphic); DateTime *dt = DateTime.Now; int gametimeh = dt.Hour; int gametimem = dt.Minute; int gametimes = dt.Second; //clock position and size ds.DrawingColor = 15; //white ds.DrawCircle(centrex, centrey, radius); ds.DrawingColor = 0; //black ds.DrawCircle(centrex, centrey, radius-1); ds.DrawingColor = 15; //white ds.DrawLine(centrex, centrey, centrex+FloatToInt(0.6*IntToFloat(radius)*Maths.Sin(Maths.DegreesToRadians(IntToFloat(gametimeh)*30.0)), eRoundNearest), centrey-FloatToInt(0.6*IntToFloat(radius)*Maths.Cos(Maths.DegreesToRadians(IntToFloat(gametimeh)*30.0)), eRoundNearest), 3); ds.DrawLine(centrex, centrey, centrex+FloatToInt(0.9*IntToFloat(radius)*Maths.Sin(Maths.DegreesToRadians(IntToFloat(gametimem)*6.0)), eRoundNearest), centrey-FloatToInt(0.9*IntToFloat(radius)*Maths.Cos(Maths.DegreesToRadians(IntToFloat(gametimem)*6.0)), eRoundNearest), 2); ds.DrawLine(centrex, centrey, centrex+FloatToInt(0.9*IntToFloat(radius)*Maths.Sin(Maths.DegreesToRadians(IntToFloat(gametimes)*6.0)), eRoundNearest), centrey-FloatToInt(0.9*IntToFloat(radius)*Maths.Cos(Maths.DegreesToRadians(IntToFloat(gametimes)*6.0)), eRoundNearest), 1); ds.Release(); this.Graphic = backgroundCopy.Graphic; backgroundCopy.Delete(); } -------------------- |
|
|
|
8 Feb 2015, 21:28
Messaggio
#2
|
|
|
Gruppo: Oldgame Editor Messaggi: 516 Iscritto il: 16 May 12 Utente Nr.: 19.376 BGE The secret of Monkey Island Playing The secret of Monkey Island SO WinVista |
CIAO VINCENT!!!! \o/
Che bello incontrarti qui! -- fine off topic LOL Lo script è ben fatto. Purtroppo AGS quando disegni e colori i pixel rallenta in effetti... Io ottimizzerei non disegnando sul fondale, ma andrei decisamente su un dynamic sprite... creando un oggetto nella stanza ad esempio oOrologio e farei una cosa del tipo: (non testata) CODICE DynamicSprite* orologio_temp = DynamicSprite.Create(... , ...); //metti le dimensioni del tuo sprite pari alle dimensioni dell'orologio... cioè raggiox2 DrawingSurface Surface = orologio_temp.GetDrawingSurface(); //disegna l'orologio come da tuo script ... Surface.Release(); oOrologio.Graphic = orologio_temp.Graphic; orologio_temp.Delete(); Non è testato... ma secondo me così ottimizzi... prova un po' e fammi sapere.. \o |
|
|
|
8 Feb 2015, 21:58
Messaggio
#3
|
|
Gruppo: Gamer Messaggi: 42 Iscritto il: 3 February 15 Da: Lecce, Italy Utente Nr.: 20.669 BGE Psychic detective Playing Phantasmagoria SO Windows7 |
GRANDISSIMO APRILSKIES !!!
SONO FELICISSIMO DI FAR PARTE DEL FORUM E D'INCONTRARTI QUI !!! ^o^ Ti ringrazio per la risposta Quindi tu consiglieresti di non disegnare direttamente sullo sfondo ma direttamente su di un oggetto Se lo disegno direttamente sulla grafica dell'object non dovrebbe rallentare in questa maniera barbara... Lo spero ci provo immediatamente e ti faccio sapere grazie mille ancora -------------------- |
|
|
|
8 Feb 2015, 22:41
Messaggio
#4
|
|
Gruppo: Gamer Messaggi: 42 Iscritto il: 3 February 15 Da: Lecce, Italy Utente Nr.: 20.669 BGE Psychic detective Playing Phantasmagoria SO Windows7 |
Ciao AprilSkies,
Ho provato il metodo che hai pensato ma c'è qualcosa che non va... Sicuramente sto sbagliando qualcosa io... Ma facendo cosi non riesco proprio a visualizzare l'oggetto nella stanza però il gioco rallenta comunque :( Forse ho sbagliato qualcosa ne sono sicuro CODICE DynamicSprite* backgroundCopy; function DrawClock(int centrex, int centrey, int radius) // ho provato a togliere l'estensione alla funzione { // vecchio // backgroundCopy = DynamicSprite.CreateFromBackground(0); // DrawingSurface *ds = Room.GetDrawingSurfaceForBackground(); // nuovo backgroundCopy = DynamicSprite.Create(oOrologio.X, oOrologio.Y); DrawingSurface *ds = backgroundCopy.GetDrawingSurface(); // come prima ds.Clear(); ds.DrawImage(0, 0, backgroundCopy.Graphic); DateTime *dt = DateTime.Now; int gametimeh = dt.Hour; int gametimem = dt.Minute; int gametimes = dt.Second; //clock position and size ds.DrawingColor = 15; //white ds.DrawCircle(centrex, centrey, radius); ds.DrawingColor = 0; //black ds.DrawCircle(centrex, centrey, radius-1); ds.DrawingColor = 15; //white ds.DrawLine(centrex, centrey, centrex+FloatToInt(0.6*IntToFloat(radius)*Maths.Sin(Maths.DegreesToRadians(IntToFloat(gametimeh)*30.0)), eRoundNearest), centrey-FloatToInt(0.6*IntToFloat(radius)*Maths.Cos(Maths.DegreesToRadians(IntToFloat(gametimeh)*30.0)), eRoundNearest), 3); ds.DrawLine(centrex, centrey, centrex+FloatToInt(0.9*IntToFloat(radius)*Maths.Sin(Maths.DegreesToRadians(IntToFloat(gametimem)*6.0)), eRoundNearest), centrey-FloatToInt(0.9*IntToFloat(radius)*Maths.Cos(Maths.DegreesToRadians(IntToFloat(gametimem)*6.0)), eRoundNearest), 2); ds.DrawLine(centrex, centrey, centrex+FloatToInt(0.9*IntToFloat(radius)*Maths.Sin(Maths.DegreesToRadians(IntToFloat(gametimes)*6.0)), eRoundNearest), centrey-FloatToInt(0.9*IntToFloat(radius)*Maths.Cos(Maths.DegreesToRadians(IntToFloat(gametimes)*6.0)), eRoundNearest), 1); ds.Release(); oOrologio.Graphic = backgroundCopy.Graphic; backgroundCopy.Delete(); } function repeatedly_execute_always() { // funzione estesa era cosi // oOrologio.DrawClock(oOrologio.X, oOrologio.Y, 35); // adesso cosi DrawClock(oOrologio.X, oOrologio.Y, 35); } Ma non riesco a visualizzare l'oggetto nella stanza :( -------------------- |
|
|
|
8 Feb 2015, 22:56
Messaggio
#5
|
|
|
Gruppo: Oldgame Editor Messaggi: 516 Iscritto il: 16 May 12 Utente Nr.: 19.376 BGE The secret of Monkey Island Playing The secret of Monkey Island SO WinVista |
Infatti non avevo testato XD
Forse puoi provare a non far cancellare lo sprite subito dopo: prova a togliere backgroundCopy.Delete(); però, a parte questo, se rallenta comunque, non abbiamo ottimizzato .... :/ Che risoluzione ha il tuo gioco di prova? A quanti frames per secondo ti cade? (visualizza gli FPS s schermo così ti rendi conto) EDIT: appena testato... sì togli backgroundCopy.Delete(); e funziona! Ovviamente come hai impostato la funzione (mettendo oggetto.X e oggetto.Y) vedrai un quarto dell'orologio... ma saprai aggiustare le coordinate e le dimensioni dell'oggetto che ricorda deve essere grande Raggio x 2 e ricorda che X e Y per l'oggetto sono lo spigolo... quindi se vuoi il centro sarebbe Oggetto.X + larghezza/2 e oggetto.Y - altezza/2. Cmq a me non rallenta ... non perde fps.. NOTA: l'ho testato in 320x200 Messaggio modificato da AprilSkies il 8 Feb 2015, 23:04 |
|
|
|
8 Feb 2015, 23:20
Messaggio
#6
|
|
Gruppo: Gamer Messaggi: 42 Iscritto il: 3 February 15 Da: Lecce, Italy Utente Nr.: 20.669 BGE Psychic detective Playing Phantasmagoria SO Windows7 |
Si... effettivamente il gioco continua sempre a rallentare...
beh... la risoluzione del game è abbastanza alta 1024x768 ...(Ma)... ad esempio io ho già implementato un dynamic sprite che fa da specchio al personaggio e la neve che scende tranquillamente verso terra.. però nessun rallentamento di nessun genere... anzi... ma quando cerco di disegnare l'orologio... amen.... (ho provato ad aprire un nuovo progetto pensando che questo rallentamento sia dovuto (al fatto che sto già facendo delle operazioni in repeatedly_execute_always (?!) ma putroppo va a rilento anche a Roger) ad una risoluzione più bassa 640x480... I frame al secondo sono -costanti già dall'inizio appena entro nella room va a rilento dai 16 ai 21 Questo è un mistero.. ma vorrei provare a fare questo backgroundCopy.Delete(); -------------------- |
|
|
|
8 Feb 2015, 23:52
Messaggio
#7
|
|
Gruppo: Gamer Messaggi: 42 Iscritto il: 3 February 15 Da: Lecce, Italy Utente Nr.: 20.669 BGE Psychic detective Playing Phantasmagoria SO Windows7 |
Siiiiiiii ha funzionato alla grandeeeeee
Felicissimo Ecco perchè anche in diverse risoluzioni mi rallentava comunque... disegnavo sempre sul background e cancellavo il dynamic sprite cosi da generare un rallentamento nell'engine pauroso... Grazie mille ancora per l'aiuto e per le dritte ( ^o^ ) Sei gentilissimo come sempre -------------------- |
|
|
|
9 Feb 2015, 08:44
Messaggio
#8
|
|
|
Gruppo: Oldgame Editor Messaggi: 516 Iscritto il: 16 May 12 Utente Nr.: 19.376 BGE The secret of Monkey Island Playing The secret of Monkey Island SO WinVista |
Perfetto!
Sì in generale il consiglio è di disegnare sempre su sprite dinamici e assegnare agli oggetti, per due motivi: - i pixel che deve "mappare" sono meno dell'intero background, quindi è più veloce - hai più controllo su quello che disegni che lo sposti tranquillamente sullo schermo con l'oggetto a cui assegni, dandogli posizioni, assegnandogli visibilità o meno, e tnte altre cose. - Riesci a mettere le cose "dietro" ad altri oggetti se serve (giocando con la baseline dell'oggetto. - ecc ecc |
|
|
|
9 Feb 2015, 13:07
Messaggio
#9
|
|
Gruppo: Gamer Messaggi: 42 Iscritto il: 3 February 15 Da: Lecce, Italy Utente Nr.: 20.669 BGE Psychic detective Playing Phantasmagoria SO Windows7 |
Si infatti, hai perfettamente ragione.
Volendo si poteva fare anche con una GUI a pensarci ma sarebbe stato limitato sotto certi aspetti. Difatti la funzione inizialmente l'avevo estesa solo per gli object.. Cioè avevo avuto l'idea giusta ma la stavo eseguendo solo male eheh Però grazie ai tuoi consigli adesso terrò a mente questi particolari fondamentali anche perchè in passato ho avuto problemi simili.. Grazie mille ancora AprilSkies -------------------- |
|
|
|
9 Feb 2015, 19:47
Messaggio
#10
|
|
|
Gruppo: Oldgame Editor Messaggi: 516 Iscritto il: 16 May 12 Utente Nr.: 19.376 BGE The secret of Monkey Island Playing The secret of Monkey Island SO WinVista |
Ma che scherzi!
Beh forse la GUi, in effetti, per questo caso specifico (cioè qualcosa che sta su schermo, in ogni stanza, per tutto il gioco....) forse forse è la scelta giusta! l'oggetto ti obbliga a mettere un oggetto in ogni stanza.. la gui è meglio.. Quindi hai avuto la giusta intuizione.. vai con la gui! |
|
|
|
![]() ![]() |
| Versione Lo-Fi | Oggi è il: 31st October 2026 - 23:36 |