java - Where do I run AI logic in MVC app.? -
i need make swing application school project let 2 ai play against each others on kind of snake game.
i used mvc design pattern , created class need basics test i'm not sure should run code makes ai plays.
the class of jpanel
want run game :
public class gamepanel extends jpanel { public gamepanel (jframe frame) { ... } public paintcomponent (graphics g) { ... // draw grid represent game } }
i tried put code makes ai plays in constructor wasn't working because need call paintcomponent()
method each time ai play (to refresh grid represent game) , can't call because getgraphics()
gives me 'null' (i can't call paintcomponent()
without instance of graphics
).
where supposed place code make ai play? i've never used swing before think i'm missing obvious, i'm kinda lost...
i hope of make sense, english not mother tongue , have troubles explain issue. hope understand meant , can me!
Comments
Post a Comment