|
Post by rosy on Nov 12, 2020 7:06:21 GMT -6
There is an easy way to run under android?
Do you have to build an apk every time, transfer it to the phone and install there?
I wanted to test some functions how they work there ...
|
|
|
Post by n00b on Nov 12, 2020 9:35:49 GMT -6
Sorry but the current android build tool is all there is. When I am building for android I usually have a function that will detect the operating system and use mouse or touch events depending on whether its on mobile or desktop. That way I can just test it on desktop with the mouse and build for mobile when I feel its ready.
Something like this:
Sub pointer(ByRef x, ByRef y, ByRef b1, ByRef b2, ByRef b3) Select Case OS Case "ANDROID","IOS" GetTouchFinger(0, x, y, b1) b1 = b1 <> 0 Default GetMouse(x, y, b1, b2, b3) End Select End Sub
This code will get the mouse position on desktop and the first finger position on mobile. b1 will be true if the left mouse button is pressed or there is a finger touching the screen on mobile.
This code only detects one finger touch and does not get pressure but shows how to wrap this functionality for different platforms.
|
|
|
Post by rosy on Nov 12, 2020 11:07:30 GMT -6
And isn't it enough to test the mouse, and that's the same as pressing the screen?
In android also you have to create windows and define cnvas? Is the default always open?
I want to check 2 fingers .. Just NumFingers?
|
|
|
Post by n00b on Nov 12, 2020 12:28:37 GMT -6
NumFingers() will return the number of fingers detected by the device. Most devices can only detect 2 or 3. Once you get the number of fingers detected you can check each finger with GetTouchFinger().
Dim finger_x[5] Dim finger_y[5] Dim finger_pressure[5]
fx = 0 fy = 0 fp = 0 For i = 0 to NumFingers()-1 GetTouchFinger(i, fx, fy, fp) finger_x[i] = fx finger_y[i] = fy finger_pressure[i] = fp Next
|
|
|
Post by rosy on Nov 12, 2020 15:15:23 GMT -6
Just download rcbasic_android_win and run build_android, do you still need to install some JAVA? I don't think I have it installed in Windows ...
|
|
|
Post by n00b on Nov 12, 2020 15:34:26 GMT -6
You won't need to install anything to run the android builder on windows. Just run it and fill in the fields and select whether you want to build a debug build or release build and click the "Build" button.
Note if you want to build for release you will need to generate a keystore. Run the genkey tool to generate a keystore and then when you start the builder you will be able to select the keystore from the dropdown.
For more instructions on this or how to change your icon refer to the readme file that is included.
|
|
|
Post by rosy on Nov 15, 2020 11:29:30 GMT -6
I run build_android, a window with options appears: Org type, Org name ... etc. I don't know what to enter there.
|
|
|
Post by n00b on Nov 16, 2020 5:42:09 GMT -6
Org type is the type of organization (com - company, org - organization). It really doesn't matter what you select.
Org Name is the organization name. You can use your Name if you want but make sure you don't have any spaces or special characters other than "_".
App Name is what you think it is. The app name should follow the same rules as org name.
The fields at the bottom are for your keystore. If you don't have one, you can make one with the included genkey tool. If you do have one then put it in the keystore folder and it should appear in the dropdown.
|
|
|
Post by rosy on Nov 16, 2020 11:51:32 GMT -6
THIS KEY IS NECESSARY?
I generated the key, filled in the fields and it shows "build failed" communicated with "debug" and "relase". Main.bas I left the one there was, for example.
BUILD FAILED C:\Users\BOB\Downloads\rcbasic_android_win\tools_r25.2.5-windows\tools\ant\build .xml:1135: The following error occurred while executing this line: C:\Users\BOB\Downloads\rcbasic_android_win\tools_r25.2.5-windows\tools\ant\build .xml:1147: C:\Users\BOB\Downloads\rcbasic_android_win\rcbasic_android\..keystore ROSY.keystore (The system cannot find the file specified)
|
|
|
Post by n00b on Nov 17, 2020 0:53:35 GMT -6
There was an error in the build tools. I fixed them. Replace the old scripts in the rcbasic_android_win folder with these. Then open both of them up and compile them ( all the build tools are written in rcbasic ). After the you just need to run build_android and it should work. Attachments:gen_key.bas (8.29 KB)
build_apk.bas (5.2 KB)
|
|
|
Post by rosy on Nov 17, 2020 10:21:24 GMT -6
Something went ... It didn't install on an older Android device, but it did on a newer one. What do these API versions mean?
The game runs slowly and not everything is correct. I guess there's a problem with these canvases. Reading pressure with mouse functions seems to work.
|
|
|
Post by n00b on Nov 17, 2020 10:54:54 GMT -6
The API versions correspond to the SDK API. You can google android SDK API level to find out more about that.
The performance has been pretty good on android from my experience. You may need to optimize your code. Without seeing your code I can't really tell you what you need to change.
To see a good example of optimization with RCBasic try building the mode7 demo for android. It is already setup to work with motion controls as well as the keyboard.
Here is some instructions on how to get it running:
1. delete all the files in RCBASIC_PROJECT_DIR folder in the android build tool 2. in the rcbasic examples go to ( examples/gfx/Mode7/ ) and build mariokart.bas 3. copy all the files in the Mode7 folder to RCBASIC_PROJECT_DIR in the android build tool 4. rename mariokart.cbc to main.cbc 5. run the android build tool to make an apk and then install it
This is doing some 3D mode7 effects along with color manipulation and runs pretty smoothly on android.
|
|
|
Post by rosy on Nov 18, 2020 7:05:40 GMT -6
It's a simple code:
Do
s=s+1
klatka = s mod 64
' przesuniecie zawartosci a$
If klatka = 0 then
xk=xk-1
a$ = Right$(a$,Len(a$)-1)
if Right$(a$,1)="1" then
a$=a$+str$(Rand(2) MOD 2)
Else
a$=a$+"1"
End If
End If
' sprawdzanie kolizji
if faza = 64 then ' koniec fazy ruchu
xk = xk + stan
faza = 0
If Mid$(A$,xk,1) = "0" then
bum=-1
End If
If Mid$(A$,xk,1) = "2" then
pkt=pkt+10
a$ = Replace$( a$, "1", xk)
End If
End If
' sprawdzanie klawiszy w fazie stania
If faza=0 then
stan = 0
If Mid$(A$,xk,1) = "0" then
' bum=bum-1
End If
If Key(K_left) OR (MouseButton(0) AND MouseX<200) then
stan = 1
ElseIf Key(K_right) OR (MouseButton(0) AND MouseX>480) then
stan = 2
End If
End If
Canvas(0)
ClearCanvas
SetColor(Bia)
DrawText("PUNKTY: "+Str$(pkt), 220, 1)
RectFill(0,390,bum,400)
' animacja postaci
x=x-1
Select Case stan
Case 0
DrawImage(5,x,y)
Case 1
DrawImage(2+Int(faza/16),x,y)
x=x+1
faza = faza+1
Case 2
y= 200 + ((faza-32)/4)^2-63
DrawImage(2+Int(faza/16),x,y)
x=x+2
faza = faza+1
End Select
' rysowanie przedmiotow
Canvas(1)
ClearCanvas
For r=0 to 10
If mid$(a$,r,1)="0" then
DrawImage(1,r*64-klatka,232)
ElseIf mid$(a$,r,1)="2" then
SetColor(Zie)
DrawText("$",r*64+16-klatka,232)
End If
DrawText("ăăă",r*64+16-klatka,256)
Next
' obracanie piasty
If klatka<16 then
DrawText("/",88,327)
DrawText("/",200,327)
DrawText("/",312,327)
DrawText("/",424,327)
DrawText("/",536,327)
ElseIf klatka<32 then
DrawText("|",88,327)
DrawText("|",200,327)
DrawText("|",312,327)
DrawText("|",424,327)
DrawText("|",536,327)
ElseIf klatka<48 then
DrawText("\\",88,327)
DrawText("\\",200,327)
DrawText("\\",312,327)
DrawText("\\",424,327)
DrawText("\\",536,327)
Else
DrawText("_",88,320)
DrawText("_",200,320)
DrawText("_",312,320)
DrawText("_",424,320)
DrawText("_",536,320)
End If
If s mod 4 = 0 then
Update
End If
bum=bum-0.005
SetImageColorMod(2,Cze)
Loop until bum<1 or x>575 or x<-64
It's a loop of stage 3.
The 1st stage (2 canvases) works quite ok.
I can't see pasted blocks (only black rectangles). Maybe WindowClip is not working properly ...
The window is scaled to full screen (this was not mentioned in the manual as well), touch reads the scaled coordinate, mouse - real.
|
|
|
Post by n00b on Nov 18, 2020 12:47:07 GMT -6
If you are using WindowClip, CanvasClip, FloodFill, or GetPixel during your render loop then it is going to cause some slow down. Try not to use them to often.
|
|
|
Post by rosy on Nov 19, 2020 4:30:30 GMT -6
I must use GetPixel. Such a simple function and how long does it work? Weird... And WindowClip I suspect that it does not work on Android.
But exactly what I pasted does not have GetPixel.
|
|