1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-11-16 16:09:42 +01:00
VVVVVV/mobile_version/src/textboxclass.as
Terry Cavanagh 72d018ea04 Update mobile version to mobile v2.2.1
The android version just got a much needed update to fix some resolution issues on devices with cutouts.

It turns out the mobile source was actually pretty out of date, like 3 versions out of date! This commit brings it up to date.

All the changes have just been about keeping the game running on modern devices, though. The biggest change was adding the Starling library to the project, which made the game GPU powered and sped the whole thing up.
2022-12-02 18:19:58 +01:00

112 lines
2.9 KiB
ActionScript

package {
import flash.geom.*;
public class textboxclass {
public function textboxclass():void {
firstcreate();
}
public function firstcreate():void {
//Like clear, only it creates the actual arrays, etc
for (iter = 0; iter < 10; iter++) {
var t:String = new String; t = "";
line.push(t);
}
xp = 0; yp = 0; w = 0; h = 0; numlines = 0; lw = 0; tl = 0; tm = 0; active = false; timer = 0;
ybuffer = -1; redraw = true;
}
public function clear():void {
//Set all values to a default, required for creating a new entity
for (iter = 0; iter < 12; iter++) {
line[iter]="";
}
textrect = new Rectangle();
xp = 0; yp = 0; w = 0; h = 0; numlines = 1; lw = 0; tl = 0; tm = 0; active = true; timer = 0;
ybuffer = -1; redraw = true;
}
public function centerx():void { resize(); xp = 160 - (w / 2); resize(); }
public function centery():void { resize(); yp = 120 - (h / 2); resize(); }
public function adjust():void {
resize();
if (xp < 10) xp = 10;
if (yp < 10) yp = 10;
if (xp + w > 310) xp = 310 - w;
if (yp + h > 230) yp = 230 - h;
resize();
}
public function initcol(rr:int, gg:int, bb:int):void {
tr = rr; tg = gg; tb = bb;
r = 0; g = 0; b = 0; tl = 0.5;
}
public function setcol(rr:int, gg:int, bb:int):void {
r = rr; g = gg; b = bb;
}
public function update():void {
if (tm == 0) {
tl += .1;
if (tl >= 1) { tl = 1; tm = 1; }
setcol(int(tr * tl), int(tg * tl), int(tb * tl));
redraw = true;
}else if (tm == 2) {
tl -= .1;
if (tl <= 0.5) { tl = 0.5; active = false; }
setcol(int(tr * tl), int(tg * tl), int(tb * tl));
redraw = true;
}
if (timer > 0) {
timer--;
if (timer == 0) tm = 2;
}
}
public function remove():void {
//tm = 2; tl = 1; //Remove mode
tm = 2; tl = 0.4; //Remove mode
}
public function removefast():void {
tm = 2; tl = 0.4; //Remove mode
}
public function resize():void {
//Set the width and height to the correct sizes
max = 0;
for (iter = 0; iter < numlines; iter++) if (line[iter].length > max) max = line[iter].length;
lw = max;
w = (max +2) * 8;
h = (numlines + 2) * 8;
textrect.x = xp; textrect.y = yp; textrect.width = w; textrect.height = h;
}
public function addline(t:String):void {
line[numlines] = t;
numlines++;
resize();
if (numlines >= 12) numlines = 0;
}
//Fundamentals
public var line:Array = new Array;
public var xp:int, yp:int, lw:int, w:int, h:int, numlines:int;
public var r:int, g:int, b:int;
public var tr:int, tg:int, tb:int;
public var textrect:Rectangle;
public var active:Boolean;
public var timer:int;
public var tl:Number, tm:int;
public var iter:int, max:int;
//For android
public var ybuffer:int;
public var redraw:Boolean;
}
}