package ru.vagrant_ai.questionmarkgame.obj.scenes;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import ru.vagrant_ai.questionmarkgame.main.Game;
import ru.vagrant_ai.questionmarkgame.main.GameplayState;
import ru.vagrant_ai.questionmarkgame.util.Dialogue;
import ru.vagrant_ai.questionmarkgame.util.Particle;
import ru.vagrant_ai.questionmarkgame.util.Text;
import ru.vagrant_ai.questionmarkgame.util.Util;
import ru.vagrant_ai.questionmarkgame.util.list.PT;
public class Intro extends Scene {
byte util_iter_black_screen = 0;
byte util_iter_scene1 = 0;
byte util_dialogue_scene = 0;
private Image player_idle, player_walk;
private Image grass, grass_small;
private Image tree[] = new Image[3];
private Image capsule;
public Intro()
{
Game.app.getInput().clearKeyPressedRecord();
tree[2] = Util.loadImage("background/hi-res/tree_hr.png");
tree[1] = Util.loadImage("background/hi-res/tree_2_hr.png");
tree[0] = Util.loadImage("background/hi-res/tree_3_hr.png");
player_idle = Util.loadImage("background/hi-res/player_idle_hr.png");
player_walk = Util.loadImage("background/hi-res/player_walk_hr.png");
grass = Util.loadImage("background/hi-res/grass_hr.png");
grass_small = Util.loadImage("background/hi-res/grass_small_hr.png");
capsule = Util.loadImage("background/hi-res/capsule_hr.png");
int loop[] = {0,0}; //set tree and grass movement
while (loop[0] < 3)
{
loop[1] = 0;
for (int i = (int) -400+loop[0]*45; i < 900; i += 130+loop[1]*(loop[0]+1))
{
if (loop[0] == 0)
layer_top_trees.add(i);
else if (loop[0] == 1)
layer_mid_trees.add(i);
else
layer_low_trees.add(i);
i += loop[0]*45;
}
for (int i = -241; i < 1198; i += 240)
{
if (loop[0] == 0)
layer_top_grass.add(i);
else if (loop[0] == 1)
layer_mid_grass.add(i);
else
layer_low_grass.add(i);
}
loop[1]++;
if (loop[1] > 8) loop[1] = 0;
loop[0]++;
}
for (int i = -241; i < 1198; i += 240)
{
layer_grass_small.add(i);
}
}
public void render(Graphics g)
{
if (util_iter_scene1 > 0)
{
switch(util_iter_scene1)
{
case 1:
draw_walking_player(g);
break;
default:
draw_scene1(g);
break;
}
}
if (util_iter_black_screen < 10)
{
util_iter_black_screen++;
if (util_iter_black_screen == 10)
{
Dialogue.modify("???","FUCK! I'm surrounded!/Goddamn fence everywhere.","hero_bad");
util_dialogue_scene++;
}
}
else
{
while (Dialogue.perform(g))
{
switch(util_dialogue_scene)
{
case 1:
Dialogue.modify("???","And, the escape plan is... Gah!/I'll improvise it a bit later.","hero_neut");
break;
case 2:
util_iter_scene1++; //1 - player appears
Dialogue.modify("???","And my name is... Yeah, I remembered it/well. But it is actually irrelevant/right now...","hero_neut");
break;
case 3:
util_iter_scene1++; //2 - forest appears
Dialogue.modify("Hero","I wonder if I could cheer myself up with/my sick rap skills. Alright, let's push/some of these phat beats out...","hero_bad");
break;
case 4:
GameplayState.sound_handler.playAudio("beat_loop", true);
Dialogue.modify("Hero","Yo! Stuck alone in a misanthrope heaven./With no single life around me.","hero_neut");
break;
case 5:
Dialogue.modify("Hero", "Wanna spit out my semen/but no way 'cause it's around seven/o'clock and I wonder what it would be", "hero_happy");
break;
case 6:
Dialogue.modify("Hero", "...when the night comes in. Now someone/show me the exit and i will flee/instantly, permanently, mapuckin' entirely!", "hero_happy");
break;
case 7:
GameplayState.sound_handler.stopAudio("beat_loop");
util_iter_scene1++; //3 - player stops
util_walk_iter = -1;
Particle.addNew(PT.EXCLAMATION, 353, 193);
Dialogue.modify("Hero", "Shit! That was pretty furious one, but I/better stop 'cause there's something in/my way!", "hero_surprised");
break;
case 8:
util_iter_scene1++; //4 - player moves, capsule appears
Dialogue.modify("Hero", "Now ya look at that! What a cute device./Let's examine it a bit. I suppose this is/a battery and a control device...", "hero_happy");
break;
case 9:
if (util_iter_scene1 != 5)
util_iter_scene1++; //5 - capsule stops, player stops
util_capsule_x_coord = 55;
Dialogue.modify("Hero", "I just wonder what's inside this capsule?/And... Lotta boxes behi...", "hero_neut");
break;
case 10:
Particle.addNew(PT.EXCLAMATION, 390, 193);
Dialogue.modify("???", "Ummm, do you hear me?", "girl_silh");
break;
case 11:
Dialogue.modify("Hero", "Omygosh! Who is speaking to me?", "hero_surprised");
break;
case 12:
Dialogue.modify("???", "My name is Minerva and I actually stuck/in this capsule.", "girl_silh");
break;
case 13:
Dialogue.modify("Hero", "Wella wella wella. And seems someone has/a day much worse than mine.", "hero_neut");
break;
case 14:
Dialogue.modify("Minerva", "Pardon? What do you mean worse? Can/you tell me about yourself first?", "girl_silh");
break;
case 15:
Dialogue.modify("Hero", "Well, i was hoping that you'll be the/first one who will give me some answers/but okay...", "hero_bad");
break;
case 16:
Dialogue.modify("Minerva", "I will tell you, I just need it for my/own safety...", "girl_silh");
break;
case 17:
Dialogue.modify("Hero", "I don't know what type of safety are you/talking about, but okay, lemme spit.", "hero_neut");
break;
case 18:
Dialogue.modify("Hero", "About three hours ago a waked up in this/forest and began to explore. Then I/found a giant fence.", "hero_bad");
break;
case 19:
Dialogue.modify("Hero", "I followed it's path and found out that/got isolated from outer world. Actually/i don't remember how i ended up here.", "hero_bad");
break;
case 20:
Dialogue.modify("Minerva", "I see. Seems like i can trust you. The/point is that it was a mad mind who/locked me up there.", "girl_silh");
break;
case 21:
Dialogue.modify("Minerva", "I was checking you weren't him. What's/your name by the way?", "girl_silh");
break;
case 22:
Dialogue.modify("Hero", "You can call me Vans, sugar.", "hero_neut");
break;
case 23:
Dialogue.modify("Minerva", "Uhh okay, Vans. I'll tell more about him/later. By the way, do you know what time/is it?", "girl_silh");
break;
case 24:
Dialogue.modify("Vans", "I don't know exactly, but it is about/night.", "hero_neut");
break;
case 25:
Dialogue.modify("Minerva", "Oh. Night here are dangerous and contain/anomalies. It's dangerous to be unarmed./There's a gun near these boxes, take it.", "girl_silh");
break;
case 26:
Dialogue.modify("Minerva", "Shoot them until sun comes. We'll talk/more until it would be safe.", "girl_silh");
break;
case 27:
Dialogue.modify("Vans", "This is gonna be fun. Alright, lets do/this shit.", "hero_happy");
break;
case 28:
GameplayState.scene_handler.deactivateScene();
default:
break;
}
util_dialogue_scene++;
}
}
draw_skip_text(g);
}
private int util_movement_effect = 300;
private List<Integer> layer_top_trees = new ArrayList<>();
private List<Integer> layer_mid_trees = new ArrayList<>();
private List<Integer> layer_low_trees = new ArrayList<>();
private List<Integer> layer_top_grass = new ArrayList<>();
private List<Integer> layer_mid_grass = new ArrayList<>();
private List<Integer> layer_low_grass = new ArrayList<>();
private List<Integer> layer_grass_small = new ArrayList<>();
private void draw_scene1(Graphics g)
{
g.setColor(new Color(54,58,214));
g.fillRect(0, 0, Game.getAppX(), 315-54*3); //sky
g.setColor(new Color(70,92,10));
g.fillRect(0, 315-54*3, Game.getAppX(), 18*3); //grass layer top
g.setColor(new Color(100,125,14));
g.fillRect(0, 315-36*3, Game.getAppX(), 18*3); //grass layer mid
g.setColor(new Color(115,160,15));
g.fillRect(0, 315-18*3, Game.getAppX(), 18*3); //grass layer low
util_movement_effect--;
if (util_movement_effect < 0)
util_movement_effect = 300;
g.setColor(new Color(145,186,20));
g.fillRect(0, 315, Game.getAppX(), 27*3); //grass layer player
draw_active_elements(g);
if (util_iter_scene1 >= 4)
draw_capsule(g);
draw_walking_player(g);
draw_front_grass(g);
g.setColor(new Color(185,122,87));
g.fillRect(0, 315+27*3, Game.getAppX(), Game.getAppY()-(315+27*3)); //earth
Particle.update_and_render_3nd_layer(g);
}
int util_walk_iter = 18;
private void draw_walking_player(Graphics g)
{
if ((util_walk_iter > 0 || util_iter_scene1 == 3) && util_iter_scene1 < 5) //stops player movement on certain scene
player_idle.draw(363, 233);
else if (util_iter_scene1 < 5)
player_walk.draw(363, 233);
else
player_idle.getFlippedCopy(true, false).draw(363, 233);
if (util_iter_scene1 != 3 && util_iter_scene1 < 5)
util_walk_iter--; //stops player movement on certain scene
if (util_walk_iter < -30)
util_walk_iter = 30;
}
int util_top_trees = 4;
int util_mid_trees = 2;
private void draw_active_elements(Graphics g)
{
util_top_trees--; //tree parallax delay
if (util_top_trees < 0)
util_top_trees = 4;
util_mid_trees--;
if (util_mid_trees < 0)
util_mid_trees = 2;
draw_top_layer(g);
draw_mid_layer(g);
draw_low_layer(g);
}
private void draw_top_layer(Graphics g)
{
for (int i = 0; i < layer_top_trees.size(); ++i) //top layer trees
{
int x = layer_top_trees.get(i);
tree[0].getFlippedCopy(true,false).draw(x, -402);
if (util_top_trees == 1 && util_iter_scene1 != 3 && util_iter_scene1 < 5) //prevents movement on certain scene
x--;
layer_top_trees.set(i, x);
}
if (util_iter_scene1 != 3 && util_iter_scene1 < 5) //pure cosmetic, not to do extra calculations
{
for (int i = 0; i < layer_top_trees.size(); ++i)
{
if (layer_top_trees.get(i) < -400)
{
layer_top_trees.remove(i);
layer_top_trees.add(900+new Random().nextInt(85));
}
}
}
for (int i = 0; i < layer_top_grass.size(); i += 1) //top layer grass
{
int x = layer_top_grass.get(i);
grass.draw(x, 117);
if (util_top_trees == 1 && util_iter_scene1 != 3 && util_iter_scene1 < 5) //prevents movement on certain scene
x--;
layer_top_grass.set(i, x);
}
if (util_iter_scene1 != 3 && util_iter_scene1 < 5) //pure cosmetic, not to do extra calculations
{
for (int i = 0; i < layer_top_grass.size(); ++i)
{
if (layer_top_grass.get(i) < -241)
{
layer_top_grass.remove(i);
layer_top_grass.add(1190);
}
}
}
}
private void draw_mid_layer(Graphics g)
{
for (int i = 0; i < layer_mid_trees.size(); ++i) //mid layer trees
{
int x = layer_mid_trees.get(i);
tree[1].getFlippedCopy(true,false).draw(x, -348);
if (util_mid_trees == 1 && util_iter_scene1 != 3 && util_iter_scene1 < 5) //prevents movement on certain scene
x--;
layer_mid_trees.set(i, x);
}
if (util_iter_scene1 != 3 && util_iter_scene1 < 5) //pure cosmetic, not to do extra calculations
{
for (int i = 0; i < layer_mid_trees.size(); ++i)
{
if (layer_mid_trees.get(i) < -400)
{
layer_mid_trees.remove(i);
layer_mid_trees.add(900+new Random().nextInt(65)+20);
}
}
}
for (int i = 0; i < layer_mid_grass.size(); i += 1) //mid layer grass
{
int x = layer_mid_grass.get(i);
grass.draw(x, 171);
if (util_mid_trees == 1 && util_iter_scene1 != 3 && util_iter_scene1 < 5) //prevents movement on certain scene
x--;
layer_mid_grass.set(i, x);
}
if (util_iter_scene1 != 3 && util_iter_scene1 < 5) //pure cosmetic, not to do extra calculations
{
for (int i = 0; i < layer_mid_grass.size(); ++i)
{
if (layer_mid_grass.get(i) < -241)
{
layer_mid_grass.remove(i);
layer_mid_grass.add(1190);
}
}
}
}
private void draw_low_layer(Graphics g)
{
for (int i = 0; i < layer_low_trees.size(); ++i) //low layer trees
{
int x = layer_low_trees.get(i);
tree[2].getFlippedCopy(true,false).draw(x, -294);
if (util_iter_scene1 != 3 && util_iter_scene1 < 5) //prevents movement on certain scene
x--;
layer_low_trees.set(i, x);
}
if (util_iter_scene1 != 3 && util_iter_scene1 < 5) //pure cosmetic, not to do extra calculations
{
for (int i = 0; i < layer_low_trees.size(); ++i)
{
if (layer_low_trees.get(i) < -400)
{
layer_low_trees.remove(i);
layer_low_trees.add(900+new Random().nextInt(65)+20);
}
}
}
for (int i = 0; i < layer_low_grass.size(); i += 1) //low layer grass
{
int x = layer_low_grass.get(i);
grass.draw(x, 224);
if (util_iter_scene1 != 3 && util_iter_scene1 < 5) //prevents movement on certain scene
x--;
layer_low_grass.set(i, x);
}
if (util_iter_scene1 != 3 && util_iter_scene1 < 5) //pure cosmetic, not to do extra calculations
{
for (int i = 0; i < layer_low_grass.size(); ++i)
{
if (layer_low_grass.get(i) < -241)
{
layer_low_grass.remove(i);
layer_low_grass.add(1190);
}
}
}
}
private int util_capsule_x_coord = 810;
private void draw_capsule(Graphics g)
{
if (util_iter_scene1 == 4 && util_capsule_x_coord != 55)
{
util_capsule_x_coord -= 2;
if (util_capsule_x_coord < 55)
util_iter_scene1 = 5;
}
if (util_iter_scene1 >= 5 && util_capsule_x_coord != 55)
util_capsule_x_coord = 55;
capsule.draw(util_capsule_x_coord, 68);
}
private void draw_front_grass(Graphics g)
{
for (int i = 0; i < layer_grass_small.size(); i += 1)
{
int x = layer_grass_small.get(i);
grass_small.draw(x, 351);
if (util_iter_scene1 != 3 && util_iter_scene1 < 5) //stops from movement
x -= 2;
layer_grass_small.set(i, x);
}
if (util_iter_scene1 != 3 && util_iter_scene1 < 5) //stops from movement
{
for (int i = 0; i < layer_grass_small.size(); ++i)
{
if (layer_grass_small.get(i) < -241)
{
layer_grass_small.remove(i);
layer_grass_small.add(1190);
}
}
}
}
private int util_skip_timer = 70;
private void draw_skip_text(Graphics g)
{
Input input = Game.app.getInput();
if (input.isKeyDown(Input.KEY_SPACE))
{
if (util_skip_timer < 45)
Text.drawString(60, Text.extractLength("Hold 'SPACE' to skip intro", 60), 7, "Hold 'SPACE' to skip intro", Color.white, 1);
else
Text.drawString(60, Text.extractLength("Hold 'SPACE' to skip intro", 60), 7, "Hold 'SPACE' to skip intro", Color.white);
util_skip_timer--;
if (util_skip_timer == 0)
GameplayState.scene_handler.deactivateScene();
}
else
{
Text.drawString(60, Text.extractLength("Hold 'SPACE' to skip intro", 60), 7, "Hold 'SPACE' to skip intro", Color.white);
util_skip_timer = 70;
}
}
}