-
Notifications
You must be signed in to change notification settings - Fork 2
/
TitleScreen_Peaches.java
336 lines (291 loc) · 9.44 KB
/
TitleScreen_Peaches.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
/////////////////////////////////////
//Jokemon Title Screen
//Peaches Version
//
//By Camtendo
//
//
//
//
import javax.sound.midi.MidiSystem;
import javax.sound.midi.Sequencer;
import javax.swing.JPanel;
import javax.swing.JApplet;
import javax.swing.JFrame;
import java.awt.Image;
import java.awt.Point;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.Toolkit;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.*;
import java.net.URL;
import java.applet.AudioClip;
public class TitleScreen_Peaches extends JPanel implements Runnable, KeyListener
{
Thread thread;
private Sequencer sequencer;
URL titleMusic, creditMusic;
Image icon,logo,mascot;
String fps="1";
long lastFPS;
int frames, slp;
final Point[] randStars=new Point[300];
final Font font=new Font("Sanserif", Font.BOLD, 60);
int creditInt;
final Font smallerMenuFont=new Font("Sanserif", Font.BOLD, 14);
final Image camtendo;
final Image justinian;
final Image jinc;
public static void main(String[] peaches)
{
TitleScreen_Peaches t=new TitleScreen_Peaches();
t.setupGUI();
t.beginThread();
}
public TitleScreen_Peaches()
{
try
{
sequencer = MidiSystem.getSequencer();
}
catch (Exception ignored){}
titleMusic=TitleScreen_Peaches.class.getResource("Music/JokemonTitleMusic.mid");
creditMusic=TitleScreen_Peaches.class.getResource("Music/credits.mid");
URL iconU=TitleScreen_Peaches.class.getResource("icon.png");
icon=Toolkit.getDefaultToolkit().getImage(iconU);
iconU=TitleScreen_Peaches.class.getResource("peaches.png");
logo=Toolkit.getDefaultToolkit().getImage(iconU);
iconU=TitleScreen_Peaches.class.getResource("mewtwo.gif");
mascot=Toolkit.getDefaultToolkit().getImage(iconU);
iconU=TitleScreen_Peaches.class.getResource("Logos/Justinian.png");
justinian=Toolkit.getDefaultToolkit().getImage(iconU);
iconU=TitleScreen_Peaches.class.getResource("Logos/Jinc.png");
jinc=Toolkit.getDefaultToolkit().getImage(iconU);
iconU=TitleScreen_Peaches.class.getResource("Logos/Camtendo.png");
camtendo=Toolkit.getDefaultToolkit().getImage(iconU);
for(int i=0; i<300; i++)
{
randStars[i]=new Point(0,0);
randStars[i].x=(int)(Math.random()*800);
randStars[i].y=(int)(Math.random()*600);
}
}
public void keyReleased(KeyEvent e){}
public void keyPressed(KeyEvent e){}
public void keyTyped(KeyEvent e){}
public void paintTitle(Graphics g)
{
g.setColor(Color.BLACK);
g.fillRect(0,0,getWidth(),getHeight());
g.setColor(Color.WHITE);
for(int i=0; i<300; i++)
{
g.fillOval(randStars[i].x,randStars[i].y,4,4);
randStars[i].x--;
if(randStars[i].x<0)
randStars[i].x=800;
}
g.setColor(Color.GREEN);
g.fillRect(0,500,800,100);
for(int i=0; i<300; i++)
{
g.drawLine(randStars[i].x-10,500,randStars[i].x,490);
g.drawLine(randStars[i].x-5,500,randStars[i].x,490);
g.drawLine(randStars[i].x,500,randStars[i].x,490);
g.drawLine(randStars[i].x+5,500,randStars[i].x,490);
g.drawLine(randStars[i].x+10,500,randStars[i].x,490);
if(randStars[i].x<0)
randStars[i].x=800;
}
g.drawImage(mascot,325,275,128,128,this);
g.drawImage(logo,165,10,this);
g.setColor(new Color(255,126,0));
g.setFont(font);
g.drawString("Peaches",250,220);
g.setColor(Color.WHITE);
if(Math.abs(randStars[0].x)%50>=10)
g.drawString("Press Spacebar",170,470);
g.drawImage(camtendo,0,500,754/4,209/4,this);
g.drawImage(justinian,680,500,471/4,247/4,this);
g.drawImage(jinc,740,0,200/4,300/4,this);
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);
paintCredits(g);
}
public void setupGUI()
{
URL iconU=TitleScreen_Peaches.class.getResource("icon.png");
icon=Toolkit.getDefaultToolkit().getImage(iconU);
iconU=TitleScreen_Peaches.class.getResource("peaches.png");
logo=Toolkit.getDefaultToolkit().getImage(iconU);
iconU=TitleScreen_Peaches.class.getResource("mewtwo.gif");
mascot=Toolkit.getDefaultToolkit().getImage(iconU);
for(int i=0; i<300; i++)
{
randStars[i]=new Point(0,0);
randStars[i].x=(int)(Math.random()*800);
randStars[i].y=(int)(Math.random()*600);
}
JFrame jf=new JFrame("Jokemon: Peaches");
Container cp=jf.getContentPane();
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.setSize(800,600);
jf.setLayout(new GridLayout(1,1));
cp.add(this);
jf.setLocationRelativeTo(null);
jf.setResizable(false);
jf.setIconImage(icon);
jf.setVisible(true);
jf.addKeyListener(this);
//jf.addMouseListener(this);
//jf.addMouseMotionListener(this);
}
public void run()
{
stopAudioAsset();
while(Integer.parseInt(fps)<80||Integer.parseInt(fps)>110)
{
frames++;
frameRateManager();
try
{
Thread.sleep(slp);
}
catch(Exception ignored){}
}
loopAudioAsset(creditMusic);
while(true)
{
repaint();
frames++;
frameRateManager();
try
{
Thread.sleep(slp);
}
catch(Exception ignored){}
}
}
public void beginThread()
{
if (thread == null)
{
thread = new Thread(this);
thread.start();
}
}
public void paintCredits(Graphics g)
{
g.setColor(new Color(255,126,0,creditInt%256));
g.fillRect(0,0,getWidth(),getHeight());
g.setFont(smallerMenuFont);
g.setColor(Color.WHITE);
g.drawImage(mascot,0,500,this);
g.drawImage(mascot,725,500,this);
g.drawImage(logo,180,600-creditInt/3,this);
g.drawString("Director-------------------------Cameron Crockrom 'Camtendo'",150,800-creditInt/3);
g.drawString("Graphic Organizer----------------Justin Begeman 'Justinian'",150,900-creditInt/3);
g.drawString("Character Design-----------------Camtendo",150,1000-creditInt/3);
g.drawString("Pokedex Design-------------------Anthony Balmer 'Wasabi Sause'",150,1100-creditInt/3);
g.drawString("Music----------------------------Camtendo and Justinian",150,1200-creditInt/3);
g.drawString("Sound Effects--------------------Camtendo",150,1300-creditInt/3);
g.drawString("Overworld Design-----------------Justinian",150,1400-creditInt/3);
g.drawString("Overworld Programming------------Braunsen Cottingham 'Patches'",150,1500-creditInt/3);
g.drawString("Overworld Programming------------Camtendo",150,1600-creditInt/3);
g.drawString("Overworld Programming------------Justinian",150,1700-creditInt/3);
g.drawString("Pokemon Programming--------------Camtendo and Justinian",150,1800-creditInt/3);
g.drawString("Game Scenario--------------------Camtendo, Justinian, and Patches",150,1900-creditInt/3);
g.drawString("Map Design-----------------------Justinian",150,2000-creditInt/3);
g.drawString("Battle Engine--------------------Camtendo and Justinian",150,2100-creditInt/3);
g.drawString("Item Design----------------------Justinian",150,2200-creditInt/3);
g.drawString("Game Mechanics-------------------Camtendo",150,2300-creditInt/3);
g.drawString("Data Security--------------------Camtendo",150,2400-creditInt/3);
g.drawString("Window Mechanics-----------------Justinian",150,2500-creditInt/3);
g.drawString("Minigames------------------------Mr. Babb, Sam Rohl, and Patches",150,2600-creditInt/3);
g.drawString("Badge Design---------------------Natalie C. Aka Justinian's Girlfriend",150,2700-creditInt/3);
g.drawString("Lead Testers---------------------Chris Hand and Patches",150,2800-creditInt/3);
g.drawString("Beta Testers------------------Babb's 3rd Period Comp Sci AP Class",150,2900-creditInt/3);
g.drawString("Battle Engine Testers------------Sam Eiserman, Karl Smith, Trevor Jackson, Kevin Hanna",150,3000-creditInt/3);
g.drawString("Battle Engine Testers------------Brian Healy, Jedd Patterson, Devin Freese",150,3100-creditInt/3);
g.drawString("Donors-----Ryan Dalton, Jeff Harris, Trogdor Jackson, That guy that made Frogger, Scoticus",150,3200-creditInt/3);
g.drawString("Special Thanks-------------------Mr. Babb, Nintendo, Oracle",150,3500-creditInt/3);
g.drawString("Special Thanks-------------------Guys who made midis, Sprite Rippers",150,3600-creditInt/3);
g.drawString("The End (Game Data has been saved!)",150,4000-creditInt/3);
creditInt++;
}
public void loopTitleMusic()
{
try
{
URL url=TitleScreen_Peaches.class.getResource("titlemusic.mid");
sequencer.open();
sequencer.setSequence(MidiSystem.getSequence(url));
sequencer.setLoopCount(Sequencer.LOOP_CONTINUOUSLY);
sequencer.start();
}
catch(Exception e)
{
System.out.println("Error while trying to play title music!");
}
}
public void stopTitleMusic()
{
sequencer.stop();
}
public void loopAudioAsset(URL url)
{
try
{
sequencer.open();
sequencer.setSequence(MidiSystem.getSequence(url));
sequencer.setLoopCount(Sequencer.LOOP_CONTINUOUSLY);
sequencer.start();
}
catch(Exception e)
{
System.out.println("Error while trying to play asset!");
}
}
public void playAudioAsset(URL url)
{
try
{
sequencer.open();
sequencer.setSequence(MidiSystem.getSequence(url));
sequencer.start();
}
catch(Exception e)
{
System.out.println("Error while trying to play asset!");
}
}
public void stopAudioAsset()
{
sequencer.stop();
}
public void frameRateManager()
{
if( lastFPS <=System.currentTimeMillis() )
{
fps=""+frames;
//System.out.println(fps);
lastFPS = System.currentTimeMillis() + 1000;
if(frames<80&&slp>0)
{
System.out.println("Low Frame Rate: "+fps);
slp--;
}
else if(frames>110)
{
System.out.println("High Frame Rate: "+fps);
slp++;
}
frames=0;
}
}
}