Share My Creation Spite-n-Malice

This is my first attempt at programming in over 10 years - mostly QuickBasic. Also, I just got a site and am learning the language - 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 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
MyX=cv(MyCard).Left 'starting location
Do while BusyFlag=True 'Attempt to force finishing of last move
Loop 'but it didn't help
For i=1 To nSteps
MyX=MyX+dx 'new x
MyY=MyY+dy 'new y
cv(MyCard).Left=MyX 'change card position
Timer4.Enabled=true '20 ms timer that makes BusyFlag False
Do While timer4.Enabled=True 'makes itself False
DoEvents 'primary time waster
cv(MyCard).Left=L 'to ensure accurate positioning
BusyFlag=False 'release flag
Timer1.Enabled=True 'this only worked if more than 2 seconds – slow
Do While Timer1.Enabled=True 'timer disables itself
End Sub


Licensed User
Looks very nice! I also like the presentation and simplicity of your website. Good work.

Tom Christman

Active Member
Licensed User
Old Vic (not the computer by any chance), very nice job and seems fun to play (just getting started and already lost to the Robot). I assume you, like me, cut your computing teeth on a VIC or Sinclair or something of that nature. B4A is a terrific find, and I'm continuing to learn from those contributing authors who are so generous with their time and knowledge. Have fun, and pass on some of your code techniques when you have a chance.


Well-Known Member
Licensed User
For some reason, I'm not finding the link for the app.

Regarding Spite-And-Malice -- I hate to show my age, but I played this a lot 35+ years ago!

Regarding moving the cards -- I don't see how the code posted does anything since it would hang at this loop:

Do while BusyFlag=True 'Attempt to force finishing of last move
Loop 'but it didn't help

BusyFlag is presumably false until you set it to true AFTER the loop, so the loop never executes. And if BusyFlag were True going into the loop, the app would hang because the loop would never end because Timer4 (whose Tick event is not shown) is supposed to set BusyFlag to false, but it is not enabled until after the loop.

I think that the movement of the cards needs to be done in the Timer_Tick event. Below is code I entered in response to a post yesterday where the poster had a similar problem in trying to "bring up" a panel. I'm not going to rework it for your code, but can see how it's being done in the Timer_Tick.

Sub Activity_Create 
   timer1.initialize("timer1", 1)  ' Dim timer1 in Process_Globals
   timer1.enabled = false 
end sub 
Sub button_click 
   counter1 = 0 ' Dim counter1 in Sub Globals 
   timer1.enabled = true 
end sub 
Sub timer1_tick  
   counter1 = counter1 + 5 
   panel.Height = counter1 
   if counter1 = 500 then 
      timer1.enabled = false 
   end if 
End Sub
Last edited:


Licensed User
Thanks for the help. You're absolutely right about the BusyFlag - I typed it in the wrong place when I put it here. The download button is in the lower right corner of the page. I've been playing this game (with cards) for 5 years and it's very challenging. I'm still getting my feet wet with web pages so it may change. Your suggestion for using a timer instead of a DoEvent delay looks good and I'll try it.