Hi,
This is my first attempt at programming in over 10 years - mostly QuickBasic. Also, I just got a site and am learning the language - DroidCardGames.com. You'll need to go there to see it since I couldn't upload my 160x240 pictures here - too big. I don't understand how everyone else knows how to do this. The Spite5.zip apk file also was too big so you'll need to get it from my site. Your comments would be greatly appreciated.
Spite and Malice is an excellent 2 person card game. In this game (my first Android game), 2 different versions can be played as human vs. robot, human vs. human, or robot vs. robot. Card speed and aggression can be controlled from the main page. A large number of variations are possible in the configuration page. A variety of different situations such as being way ahead or behind, trying to cheat, etc. can be expressed by 4 possible TTS sentences. Each group of speeches can be modified for pitch and speed.
The program started with nfordbscndrd's Card Game Shell and then I added a lot of tutorials to it. Erel was a lot of help, especially with clearing my confusion about using Dim TagData every time within a loop. The B4A program is wonderful.
Since I'm a newbie, my main problem was in my making stupid mistakes. Although the keyboard acted perfectly in the emulator, it kept popping up in a device. I had to kill it by putting DoEvents-ph.HideKeyBoard(Activity)-DoEvents at the end of each page as well as at the beginning of a new panel. The full keyboard was erroneously popping up even though I only ever called the NUMBER keyboard. I also found that I had to reduce the size of graphics before I used them. Big pictures worked OK in the emulator but Android devices just showed a plain square.
I'm still having a problem with the routine to move cards. It works in the emulator but often ends with 2 copies of a card when used in a 1200x800 tablet. One is in the final position but a false copy is in the previous position (nSteps-1) which is a few pixels away. After a few other cards have moved this false copy disappears. The code below shows my attempts at using BusyFlags and timers to solve this problem. Nothing helped except when I used very slow timer times. Any help here would be greatly appreciated. Regardless, I think you'll have fun playing this game.
Sub MoveMe(NewX as Int,NewY as Int)
Dim nSteps,i,FarX,FarY,Distance as Int
Dim dx,dy,MyX,MyY as Float
FarX=NewX-cv(MyCard).Left 'horizontal distance
FarY=NewY-cv(MyCard).top 'MyCard is the card array number
Distance=Abs(FarX)+Abs(FarY) 'crude distance
nSteps=Distance/Speed 'Speed comes from a slide bar
dy=FarY/nSteps ,size of each vertical step
dx=FarX/nSteps
MyX=cv(MyCard).Left 'starting location
MyY=cv(MyCard).Top
Do while BusyFlag=True 'Attempt to force finishing of last move
Loop 'but it didn't help
BusyFlag=True
For i=1 To nSteps
MyX=MyX+dx 'new x
MyY=MyY+dy 'new y
cv(MyCard).Left=MyX 'change card position
cv(MyCard).top=MyY
BusyFlag=true
Timer4.Enabled=true '20 ms timer that makes BusyFlag False
Do While timer4.Enabled=True 'makes itself False
DoEvents 'primary time waster
Loop
Next
cv(MyCard).Left=L 'to ensure accurate positioning
cv(MyCard).Top=T
BusyFlag=False 'release flag
Timer1.Enabled=True 'this only worked if more than 2 seconds – slow
Do While Timer1.Enabled=True 'timer disables itself
DoEvents
Loop
End Sub
This is my first attempt at programming in over 10 years - mostly QuickBasic. Also, I just got a site and am learning the language - DroidCardGames.com. You'll need to go there to see it since I couldn't upload my 160x240 pictures here - too big. I don't understand how everyone else knows how to do this. The Spite5.zip apk file also was too big so you'll need to get it from my site. Your comments would be greatly appreciated.
Spite and Malice is an excellent 2 person card game. In this game (my first Android game), 2 different versions can be played as human vs. robot, human vs. human, or robot vs. robot. Card speed and aggression can be controlled from the main page. A large number of variations are possible in the configuration page. A variety of different situations such as being way ahead or behind, trying to cheat, etc. can be expressed by 4 possible TTS sentences. Each group of speeches can be modified for pitch and speed.
The program started with nfordbscndrd's Card Game Shell and then I added a lot of tutorials to it. Erel was a lot of help, especially with clearing my confusion about using Dim TagData every time within a loop. The B4A program is wonderful.
Since I'm a newbie, my main problem was in my making stupid mistakes. Although the keyboard acted perfectly in the emulator, it kept popping up in a device. I had to kill it by putting DoEvents-ph.HideKeyBoard(Activity)-DoEvents at the end of each page as well as at the beginning of a new panel. The full keyboard was erroneously popping up even though I only ever called the NUMBER keyboard. I also found that I had to reduce the size of graphics before I used them. Big pictures worked OK in the emulator but Android devices just showed a plain square.
I'm still having a problem with the routine to move cards. It works in the emulator but often ends with 2 copies of a card when used in a 1200x800 tablet. One is in the final position but a false copy is in the previous position (nSteps-1) which is a few pixels away. After a few other cards have moved this false copy disappears. The code below shows my attempts at using BusyFlags and timers to solve this problem. Nothing helped except when I used very slow timer times. Any help here would be greatly appreciated. Regardless, I think you'll have fun playing this game.
Sub MoveMe(NewX as Int,NewY as Int)
Dim nSteps,i,FarX,FarY,Distance as Int
Dim dx,dy,MyX,MyY as Float
FarX=NewX-cv(MyCard).Left 'horizontal distance
FarY=NewY-cv(MyCard).top 'MyCard is the card array number
Distance=Abs(FarX)+Abs(FarY) 'crude distance
nSteps=Distance/Speed 'Speed comes from a slide bar
dy=FarY/nSteps ,size of each vertical step
dx=FarX/nSteps
MyX=cv(MyCard).Left 'starting location
MyY=cv(MyCard).Top
Do while BusyFlag=True 'Attempt to force finishing of last move
Loop 'but it didn't help
BusyFlag=True
For i=1 To nSteps
MyX=MyX+dx 'new x
MyY=MyY+dy 'new y
cv(MyCard).Left=MyX 'change card position
cv(MyCard).top=MyY
BusyFlag=true
Timer4.Enabled=true '20 ms timer that makes BusyFlag False
Do While timer4.Enabled=True 'makes itself False
DoEvents 'primary time waster
Loop
Next
cv(MyCard).Left=L 'to ensure accurate positioning
cv(MyCard).Top=T
BusyFlag=False 'release flag
Timer1.Enabled=True 'this only worked if more than 2 seconds – slow
Do While Timer1.Enabled=True 'timer disables itself
DoEvents
Loop
End Sub