package b4j.Valentin1;


import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.debug.*;

public class main extends javafx.application.Application{
public static main mostCurrent = new main();

public static BA ba;
static {
		ba = new  anywheresoftware.b4a.ShellBA("b4j.Valentin1", "b4j.Valentin1.main", null);
		ba.loadHtSubs(main.class);
        if (ba.getClass().getName().endsWith("ShellBA")) {
			anywheresoftware.b4a.ShellBA.delegateBA = new anywheresoftware.b4j.objects.FxBA("b4j.Valentin1", null, null);
			ba.raiseEvent2(null, true, "SHELL", false);
			ba.raiseEvent2(null, true, "CREATE", true, "b4j.Valentin1.main", ba);
		}
	}
    public static Class<?> getObject() {
		return main.class;
	}

 
    public static void main(String[] args) {
    	launch(args);
    }
    public void start (javafx.stage.Stage stage) {
        try {
            anywheresoftware.b4j.objects.FxBA.application = this;
		    anywheresoftware.b4a.keywords.Common.setDensity(javafx.stage.Screen.getPrimary().getDpi());
            anywheresoftware.b4a.keywords.Common.LogDebug("Program started.");
            initializeProcessGlobals();
            anywheresoftware.b4j.objects.Form frm = new anywheresoftware.b4j.objects.Form();
            frm.initWithStage(ba, stage, 900, 600);
            ba.raiseEvent(null, "appstart", frm, (String[])getParameters().getRaw().toArray(new String[0]));
        } catch (Throwable t) {
            BA.printException(t, true);
            System.exit(1);
        }
    }


private static boolean processGlobalsRun;
public static void initializeProcessGlobals() {
    
    if (main.processGlobalsRun == false) {
	    main.processGlobalsRun = true;
		try {
		        		
        } catch (Exception e) {
			throw new RuntimeException(e);
		}
    }
}public static anywheresoftware.b4a.keywords.Common __c = null;
public static anywheresoftware.b4j.objects.JFX _fx = null;
public static anywheresoftware.b4j.objects.Form _mainform = null;
public static anywheresoftware.b4j.objects.ButtonWrapper _btnstart = null;
public static anywheresoftware.b4j.objects.CanvasWrapper _cvsgame = null;
public static anywheresoftware.b4j.objects.PaneWrapper.ConcretePaneWrapper _pnlracket = null;
public static anywheresoftware.b4j.objects.SliderWrapper _sldspeed = null;
public static anywheresoftware.b4j.objects.SliderWrapper _sldracketheight = null;
public static double _racketleft = 0;
public static double _rackettop = 0;
public static double _racketmaxtop = 0;
public static double _racketwidth = 0;
public static double _racketheight = 0;
public static double _racketheightmin = 0;
public static double _racketheightmax = 0;
public static double _ballleft = 0;
public static double _balltop = 0;
public static double _ballmaxtop = 0;
public static double _ballwidth = 0;
public static double _ballheight = 0;
public static double _ballracketleft = 0;
public static double _balldeltaxmin = 0;
public static double _balldeltaxmax = 0;
public static double _balldeltax0 = 0;
public static double _balldeltax = 0;
public static double _balldeltay = 0;
public static double _sgnx = 0;
public static anywheresoftware.b4a.objects.Timer _tmrball = null;
public static String  _appstart(anywheresoftware.b4j.objects.Form _form1,String[] _args) throws Exception{
RDebugUtils.currentModule="main";
if (Debug.shouldDelegate(ba, "appstart"))
	return (String) Debug.delegate(ba, "appstart", new Object[] {_form1,_args});
RDebugUtils.currentLine=65536;
 //BA.debugLineNum = 65536;BA.debugLine="Sub AppStart (Form1 As Form, Args() As String)";
RDebugUtils.currentLine=65537;
 //BA.debugLineNum = 65537;BA.debugLine="tmrBall.Initialize(\"tmrBall\", 20)";
_tmrball.Initialize(ba,"tmrBall",(long) (20));
RDebugUtils.currentLine=65539;
 //BA.debugLineNum = 65539;BA.debugLine="MainForm = Form1";
_mainform = _form1;
RDebugUtils.currentLine=65540;
 //BA.debugLineNum = 65540;BA.debugLine="MainForm.RootPane.LoadLayout(\"Main\") 'Load the la";
_mainform.getRootPane().LoadLayout(ba,"Main");
RDebugUtils.currentLine=65541;
 //BA.debugLineNum = 65541;BA.debugLine="MainForm.Show";
_mainform.Show();
RDebugUtils.currentLine=65543;
 //BA.debugLineNum = 65543;BA.debugLine="BallWidth = 8";
_ballwidth = 8;
RDebugUtils.currentLine=65544;
 //BA.debugLineNum = 65544;BA.debugLine="BallHeight = BallWidth";
_ballheight = _ballwidth;
RDebugUtils.currentLine=65545;
 //BA.debugLineNum = 65545;BA.debugLine="BallLeft = 0";
_ballleft = 0;
RDebugUtils.currentLine=65546;
 //BA.debugLineNum = 65546;BA.debugLine="BallTop = cvsGame.Height / 2 - BallHeight / 2";
_balltop = _cvsgame.getHeight()/(double)2-_ballheight/(double)2;
RDebugUtils.currentLine=65547;
 //BA.debugLineNum = 65547;BA.debugLine="BallMaxTop = cvsGame.Height - BallHeight";
_ballmaxtop = _cvsgame.getHeight()-_ballheight;
RDebugUtils.currentLine=65548;
 //BA.debugLineNum = 65548;BA.debugLine="BallRacketLeft = RacketLeft - BallWidth";
_ballracketleft = _racketleft-_ballwidth;
RDebugUtils.currentLine=65549;
 //BA.debugLineNum = 65549;BA.debugLine="BallDeltaXMin = 3";
_balldeltaxmin = 3;
RDebugUtils.currentLine=65550;
 //BA.debugLineNum = 65550;BA.debugLine="BallDeltaXMax = 20";
_balldeltaxmax = 20;
RDebugUtils.currentLine=65551;
 //BA.debugLineNum = 65551;BA.debugLine="BallDeltaX0 = 6";
_balldeltax0 = 6;
RDebugUtils.currentLine=65552;
 //BA.debugLineNum = 65552;BA.debugLine="BallDeltaX = BallDeltaX0";
_balldeltax = _balldeltax0;
RDebugUtils.currentLine=65553;
 //BA.debugLineNum = 65553;BA.debugLine="SgnX = 1";
_sgnx = 1;
RDebugUtils.currentLine=65555;
 //BA.debugLineNum = 65555;BA.debugLine="InitScreen";
_initscreen();
RDebugUtils.currentLine=65557;
 //BA.debugLineNum = 65557;BA.debugLine="DrawBall(200, 200)";
_drawball(200,200);
RDebugUtils.currentLine=65558;
 //BA.debugLineNum = 65558;BA.debugLine="End Sub";
return "";
}
public static String  _initscreen() throws Exception{
RDebugUtils.currentModule="main";
if (Debug.shouldDelegate(ba, "initscreen"))
	return (String) Debug.delegate(ba, "initscreen", null);
RDebugUtils.currentLine=851968;
 //BA.debugLineNum = 851968;BA.debugLine="Private Sub InitScreen";
RDebugUtils.currentLine=851969;
 //BA.debugLineNum = 851969;BA.debugLine="cvsGame.DrawRect(0, 0, cvsGame.Width, cvsGame.Hei";
_cvsgame.DrawRect(0,0,_cvsgame.getWidth(),_cvsgame.getHeight(),_fx.Colors.Black,anywheresoftware.b4a.keywords.Common.True,1);
RDebugUtils.currentLine=851976;
 //BA.debugLineNum = 851976;BA.debugLine="End Sub";
return "";
}
public static String  _drawball(double _x,double _y) throws Exception{
RDebugUtils.currentModule="main";
if (Debug.shouldDelegate(ba, "drawball"))
	return (String) Debug.delegate(ba, "drawball", new Object[] {_x,_y});
RDebugUtils.currentLine=917504;
 //BA.debugLineNum = 917504;BA.debugLine="Private Sub DrawBall(X As Double, Y As Double)";
RDebugUtils.currentLine=917505;
 //BA.debugLineNum = 917505;BA.debugLine="cvsGame.DrawRect(BallLeft - 2, BallTop - 2, BallW";
_cvsgame.DrawRect(_ballleft-2,_balltop-2,_ballwidth+4,_ballheight+4,_fx.Colors.Black,anywheresoftware.b4a.keywords.Common.True,1);
RDebugUtils.currentLine=917506;
 //BA.debugLineNum = 917506;BA.debugLine="BallLeft = X";
_ballleft = _x;
RDebugUtils.currentLine=917507;
 //BA.debugLineNum = 917507;BA.debugLine="BallTop = Y";
_balltop = _y;
RDebugUtils.currentLine=917508;
 //BA.debugLineNum = 917508;BA.debugLine="cvsGame.DrawRect(BallLeft, BallTop, BallWidth, Ba";
_cvsgame.DrawRect(_ballleft,_balltop,_ballwidth,_ballheight,_fx.Colors.White,anywheresoftware.b4a.keywords.Common.True,1);
RDebugUtils.currentLine=917509;
 //BA.debugLineNum = 917509;BA.debugLine="End Sub";
return "";
}
public static String  _btnstart_mouseclicked(anywheresoftware.b4j.objects.NodeWrapper.MouseEventWrapper _eventdata) throws Exception{
RDebugUtils.currentModule="main";
if (Debug.shouldDelegate(ba, "btnstart_mouseclicked"))
	return (String) Debug.delegate(ba, "btnstart_mouseclicked", new Object[] {_eventdata});
RDebugUtils.currentLine=1048576;
 //BA.debugLineNum = 1048576;BA.debugLine="Sub btnStart_MouseClicked (EventData As MouseEvent";
RDebugUtils.currentLine=1048577;
 //BA.debugLineNum = 1048577;BA.debugLine="If btnStart.Text = \"GO\" Then";
if ((_btnstart.getText()).equals("GO")) { 
RDebugUtils.currentLine=1048578;
 //BA.debugLineNum = 1048578;BA.debugLine="btnStart.Text = \"STOP\"";
_btnstart.setText("STOP");
RDebugUtils.currentLine=1048579;
 //BA.debugLineNum = 1048579;BA.debugLine="pnlRacket.MouseCursor = fx.Cursors.NONE";
_pnlracket.setMouseCursor(_fx.Cursors.NONE);
RDebugUtils.currentLine=1048580;
 //BA.debugLineNum = 1048580;BA.debugLine="tmrBall.Enabled = True";
_tmrball.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 }else {
RDebugUtils.currentLine=1048582;
 //BA.debugLineNum = 1048582;BA.debugLine="btnStart.Text = \"GO\"";
_btnstart.setText("GO");
RDebugUtils.currentLine=1048583;
 //BA.debugLineNum = 1048583;BA.debugLine="pnlRacket.MouseCursor = fx.Cursors.DEFAULT";
_pnlracket.setMouseCursor(_fx.Cursors.DEFAULT);
RDebugUtils.currentLine=1048584;
 //BA.debugLineNum = 1048584;BA.debugLine="InitScreen";
_initscreen();
RDebugUtils.currentLine=1048585;
 //BA.debugLineNum = 1048585;BA.debugLine="tmrBall.Enabled = False";
_tmrball.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 };
RDebugUtils.currentLine=1048587;
 //BA.debugLineNum = 1048587;BA.debugLine="End Sub";
return "";
}
public static String  _tmrball_tick() throws Exception{
RDebugUtils.currentModule="main";
if (Debug.shouldDelegate(ba, "tmrball_tick"))
	return (String) Debug.delegate(ba, "tmrball_tick", null);
double _x = 0;
double _y = 0;
RDebugUtils.currentLine=983040;
 //BA.debugLineNum = 983040;BA.debugLine="Private Sub tmrBall_Tick";
RDebugUtils.currentLine=983041;
 //BA.debugLineNum = 983041;BA.debugLine="Private X, Y As Double";
_x = 0;
_y = 0;
RDebugUtils.currentLine=983043;
 //BA.debugLineNum = 983043;BA.debugLine="Y = BallTop + BallDeltaY";
_y = _balltop+_balldeltay;
RDebugUtils.currentLine=983044;
 //BA.debugLineNum = 983044;BA.debugLine="If Y <= 0 Then";
if (_y<=0) { 
RDebugUtils.currentLine=983045;
 //BA.debugLineNum = 983045;BA.debugLine="Y = 0";
_y = 0;
RDebugUtils.currentLine=983046;
 //BA.debugLineNum = 983046;BA.debugLine="BallDeltaY = - BallDeltaY";
_balldeltay = -_balldeltay;
 }else 
{RDebugUtils.currentLine=983048;
 //BA.debugLineNum = 983048;BA.debugLine="Else If Y >= BallMaxTop Then";
if (_y>=_ballmaxtop) { 
RDebugUtils.currentLine=983049;
 //BA.debugLineNum = 983049;BA.debugLine="Y = BallMaxTop";
_y = _ballmaxtop;
RDebugUtils.currentLine=983050;
 //BA.debugLineNum = 983050;BA.debugLine="BallDeltaY = - BallDeltaY";
_balldeltay = -_balldeltay;
 }};
RDebugUtils.currentLine=983053;
 //BA.debugLineNum = 983053;BA.debugLine="X = BallLeft + BallDeltaX";
_x = _ballleft+_balldeltax;
RDebugUtils.currentLine=983055;
 //BA.debugLineNum = 983055;BA.debugLine="If X <= 0 Then";
if (_x<=0) { 
RDebugUtils.currentLine=983056;
 //BA.debugLineNum = 983056;BA.debugLine="X = 0";
_x = 0;
RDebugUtils.currentLine=983057;
 //BA.debugLineNum = 983057;BA.debugLine="BallDeltaX = BallDeltaX0";
_balldeltax = _balldeltax0;
RDebugUtils.currentLine=983058;
 //BA.debugLineNum = 983058;BA.debugLine="SgnX = 1";
_sgnx = 1;
 }else 
{RDebugUtils.currentLine=983059;
 //BA.debugLineNum = 983059;BA.debugLine="Else If X >= BallRacketLeft And Y >= RacketTop An";
if (_x>=_ballracketleft && _y>=_rackettop && _y<=_rackettop+_racketheight-_ballheight) { 
RDebugUtils.currentLine=983060;
 //BA.debugLineNum = 983060;BA.debugLine="X = BallRacketLeft - 5";
_x = _ballracketleft-5;
RDebugUtils.currentLine=983061;
 //BA.debugLineNum = 983061;BA.debugLine="BallDeltaX = - BallDeltaX0";
_balldeltax = -_balldeltax0;
RDebugUtils.currentLine=983062;
 //BA.debugLineNum = 983062;BA.debugLine="SgnX = -1";
_sgnx = -1;
 }else 
{RDebugUtils.currentLine=983063;
 //BA.debugLineNum = 983063;BA.debugLine="Else If X > cvsGame.Width Then";
if (_x>_cvsgame.getWidth()) { 
RDebugUtils.currentLine=983064;
 //BA.debugLineNum = 983064;BA.debugLine="X = - BallWidth";
_x = -_ballwidth;
RDebugUtils.currentLine=983065;
 //BA.debugLineNum = 983065;BA.debugLine="Y = (cvsGame.Height - BallHeight) / 2";
_y = (_cvsgame.getHeight()-_ballheight)/(double)2;
RDebugUtils.currentLine=983067;
 //BA.debugLineNum = 983067;BA.debugLine="tmrBall.Enabled = False";
_tmrball.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 }}};
RDebugUtils.currentLine=983071;
 //BA.debugLineNum = 983071;BA.debugLine="DrawBall(X, Y)";
_drawball(_x,_y);
RDebugUtils.currentLine=983072;
 //BA.debugLineNum = 983072;BA.debugLine="End Sub";
return "";
}
}