Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Animacion {
- PImage[] images;
- int imageCount;
- int frame;
- Animacion(String imagePrefix, int count) {
- imageCount = count;
- images = new PImage[imageCount];
- for (int i = 0; i < imageCount; i++) {
- // Use nf() to number format 'i' into four digits
- String filename = imagePrefix + nf(i, 4) + ".png";
- images[i] = loadImage(filename);
- }
- }
- void display(float xpos, float ypos) {
- frame = (frame+1) % imageCount;
- images[frame].resize(width,height);
- image(images[frame], xpos, ypos);
- }
- int getWidth() {
- return images[0].width;
- }
- }// La mami de los objetos
- class Objeto
- {
- int ancho, alto;
- float posx, posy;
- PImage imgObjeto;
- PVector vel; // tienes un valor para la x y un valor en y, tiene sun objeto y le dices la posicion (se va a mover en los ejes tal)
- Objeto(float posx, float posy, int ancho, int alto, String imgObjeto, PVector vel) {
- this.posx = posx;
- this.posy = posy;
- this.ancho = ancho;
- this.alto = alto;
- this.vel = vel;
- this.imgObjeto = loadImage(imgObjeto);
- }
- void dibujar()
- {
- imgObjeto.resize(ancho, alto);
- image(imgObjeto, posx, posy);
- }
- void mover() {
- posx = posx + int(vel.x);
- }
- void mover2() {
- posy = posy + int(vel.y);
- }
- void zoomout() {
- ancho = ancho -100;
- alto = alto -100;
- }
- }class Pagina
- {
- int PaginaApli;
- Tiempo tiempoPagina;
- Pagina (int p)
- {
- PaginaApli=p;
- tiempoPagina= new Tiempo();
- }
- int getPagina()
- {
- return PaginaApli;
- }
- Tiempo getCronoPagina()
- {
- return tiempoPagina;
- }
- void setPagina(int nuevaPagina)
- {
- PaginaApli=nuevaPagina;
- if ((nuevaPagina==0)||(nuevaPagina==1)) tiempoPagina.restart();
- PaginaApli=nuevaPagina;
- }
- }class Personaje extends Objeto
- { PImage aspecto1, aspecto2, aspecto3, aspecto4, aspecto5;
- Personaje(float posx, float posy, int ancho, int alto, String aspecto1, String aspecto2, String aspecto3, String aspecto4, String aspecto5, PVector vel)
- { super(posx, posy, ancho, alto, aspecto1, vel);
- this.aspecto1 = loadImage(aspecto1);
- this.aspecto2 = loadImage(aspecto2);
- this.aspecto3 = loadImage(aspecto3);
- this.aspecto4 = loadImage(aspecto4);
- this.aspecto5 = loadImage(aspecto5);
- }
- Personaje(float posx, float posy, int ancho, int alto, String aspecto1, String aspecto2, String aspecto3, PVector vel)
- { super(posx, posy, ancho, alto, aspecto1, vel);
- this.aspecto1 = loadImage(aspecto1);
- this.aspecto2 = loadImage(aspecto2);
- this.aspecto3 = loadImage(aspecto3);
- }
- Personaje(float posx, float posy, int ancho, int alto, String aspecto1, String aspecto2, String aspecto3, String aspecto4, PVector vel)
- { super(posx, posy, ancho, alto, aspecto1, vel);
- this.aspecto1 = loadImage(aspecto1);
- this.aspecto2 = loadImage(aspecto2);
- this.aspecto3 = loadImage(aspecto3);
- this.aspecto4 = loadImage(aspecto3);
- }
- Personaje(float posx, float posy, int ancho, int alto, String aspecto1, String aspecto2, PVector vel)
- { super(posx, posy, ancho, alto, aspecto1, vel);
- this.aspecto1 = loadImage(aspecto1);
- this.aspecto2 = loadImage(aspecto2);
- }
- void dibujarAspecto1(){
- aspecto1.resize(ancho,alto);
- image(aspecto1, posx, posy);
- }
- void dibujarAspecto2(){
- aspecto2.resize(ancho,alto);
- image(aspecto2, posx, posy);
- }
- void dibujarAspecto3(){
- aspecto1.resize(ancho,alto);
- image(aspecto1, posx, posy);
- }
- void dibujarAspecto4(){
- aspecto2.resize(ancho,alto);
- image(aspecto2, posx, posy);
- }
- void dibujarAspecto5(){
- aspecto2.resize(ancho,alto);
- image(aspecto2, posx, posy);
- }
- }
- class MsgBox {
- // the text and a holder
- String text, displayText;
- //positioning
- PVector bgPos, textPos;
- float w, h;
- //font and color
- color textColor =#CCCEBD, bgColor = color(20,200);
- PFont font;
- //timimng
- int timer, wait;
- //it takes the text, positioning stuff and init everything
- MsgBox(String _tx, PVector _bg, PFont _f) {
- bgPos = _bg;
- font = _f;
- w = 600;
- h = 150;
- text = _tx;
- displayText = text;
- textFont(font, 20);
- //calc text pos relative to bg pos
- textPos = new PVector(bgPos.x + 105, (bgPos.y + 390));
- // the speed of "typing"
- wait = 40;
- }
- void run() {
- update();
- display();
- }//run
- void display() {
- drawBg();
- drawText();
- }//display
- void setText(String s) {
- if (!text.equals(s)) {
- text = s;
- displayText = text;
- }
- }//setText
- void animateText() {
- displayText = "";
- timer = millis();
- }//animateText
- void update() {
- if (!isFinished() && (millis() - timer) > wait) {
- displayText = text.substring(0, displayText.length()+1);
- timer = millis();
- }
- }//update()
- boolean isFinished() {
- return displayText.length() == text.length();
- }//isFinished
- void drawBg() {
- rectMode(CORNER);
- noStroke();
- fill(bgColor);
- rect(bgPos.x+70, bgPos.y+350, w, h);
- }//drawBg
- void drawText() {
- fill(textColor);
- text(displayText, textPos.x, textPos.y);
- }//drawText
- //drawBullet*/
- }//MsgBoxclass Tiempo
- {
- long initialTiempo;
- long currentTiempo;
- Tiempo()
- {
- initialTiempo=System.currentTimeMillis();
- }
- void restart()
- {
- initialTiempo=System.currentTimeMillis();
- }
- long timingT()
- {
- currentTiempo= System.currentTimeMillis()- initialTiempo;
- return currentTiempo;
- }
- void represent()
- {
- currentTiempo= (System.currentTimeMillis()- initialTiempo)/1000;
- fill(255, 0, 0);
- text(currentTiempo, 620, 60);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement