Quote: "because english is not my mother`s"
XD
should be "engllish is not my mother language". What you said is that your mother doesn't own english.
Anyways, that code is good for a start, but you really can't code a whole game like that. what developers do when they have, say, 10 different images with 10 different states each, they don't write 100 if statements, they use
variables, for
loops,
types,
arrays, and
functions.
for example, copy and paste this code into the editor:
type button
x as integer `x position on the screen| top left corner
y as integer `y position on the screen|
w as integer `width of the button
h as integer `height of the button
color as dword
mouseovercolor as dword
clickcolor as dword
endtype
dim arr(-1) as button
for temp=0 to 1000
addButton(rnd(screen width()-40),rnd(screen height()-16),40,16,rgb(rnd(255),0,0),rgb(0,rnd(255),0),rgb(0,0,rnd(255)))
next
do
cls
for temp=0 to 1000
showButton(temp)
next
sync
loop
end
function addButton(x as integer, y as integer, w as integer, h as integer, color as dword, mouseovercolor as dword, clickcolor as dword)
array insert at bottom arr()
arr(array count(arr())).x=x
arr(array count(arr())).y=y
arr(array count(arr())).w=w
arr(array count(arr())).h=h
arr(array count(arr())).color=color
arr(array count(arr())).mouseovercolor=mouseovercolor
arr(array count(arr())).clickcolor=clickcolor
endfunction
function showButton(n as integer)
if mousex()>arr(n).x and mousex()<arr(n).x+arr(n).w and mousey()>arr(n).y and mousey()<arr(n).y+arr(n).h
if mouseclick()
ink arr(n).clickcolor,arr(n).clickcolor
else
ink arr(n).mouseovercolor,arr(n).mouseovercolor
endif
else
ink arr(n).color,arr(n).color
endif
box arr(n).x,arr(n).y,arr(n).x+arr(n).w,arr(n).y+arr(n).h
endfunction
That code probably uses a lot of new concepts (you probably aren't familiar with user defined types, explicitly declaring variables "as integer", colors and dwords, expanding arrays/array insert at bottom, etc.), but at the same time, it's shorter, and can be expanded to any number of buttons easily!
that's what I love about coding. If you find yourself doing a LOT of repetitive coding, it's a good idea to stop for a second and think of another way to go about doing what it is you want to do.
For a tic tac toe game (it looks like that is what you're doing), here are the changes I would suggest you make to your code, without really going into the other concepts I mentioned above:
declare "location(8)" as "dim location(2,2). this would create an array looking like this:
location(0,0) location(0,1) location(0,2)
location(1,0) location(1,1) location(1,2)
location(2,0) location(2,1) location(2,2)
and would probably be easier to wotk with.
then, make a
function to draw a circle at a given location (so you could call something like "drawcircle(1,1)" to draw a circle at the given location.
then, try to replace those repetitive if statements with for loops.
It's a lot to take in, I know... but really the only way to go is to keep trying to wrap your head around everything, and eventually it'll all be easy (eventually).
Is't life, I ask, is't even prudence, to bore thyself and bore thy students?