Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

Design decisions / advice for a simple game on Android -


i need advice on best way implement scrollable playing field in simple game. field consists of multiple rows, 9 cells in each row. rows can dynamically added , removed during course of game. each cell has digit in it, , optionally several overlayed images, selection, selector over, crossed out, etc. (see pic below). user should able click on individual cells of row select/deselect/cross touched cells. @ point in game there can 0 3000 cells (0 333 rows). field should scroll , down smoothly.

alt text

i thinking having listview each row being row on field. way add/remove rows dynamically during game. however, how should implement row: have 1 bitmap representing row, , when user touches -- coordinates of touch area, , find out cell affected, , act upon that. possible touch coordinates of row in listview? if not, should place 9 dummy image placeholders in each row, , act on user touching those? performance?

or should have 1 huge bitmap / canvas representing entire field, place inside scrollview , calculate coordinates , update user interacts it? going faster or slower listview?

any other solutions?

i prefer "regular" app type game, not loop-based game, don't think need redraw 30 times second.

i pretty new android. thank suggestions.

you can make kind of setup run "game loop" / surfaceview combination. means no listview, custom drawing , event handling. luckily event handling isn't difficult, , you'll win later on because you'll have greater control on interface if had gone bunch of customized views , layouts.

i'd avoid www.droidnova.com tutorial, uses hashmaps unnecessarily, cost in performance.

here's how i'd go it:

  1. create object hold cell data. example, i'd use object id (to print), , x , y draw on screen.
  2. decide on board size fit on screen without scrolling, 10x10. you'll add scrolling later.
  3. create 2-dimensional array of cell objects lengths boardsize x boardsize. fill objects id , x , y position on screen.
  4. in custom ondraw, iterate through each "row" , "column" of single array , draw object @ stored x , y value.

so you've got grid of objects displaying on screen. want restrict number of rows displayed , add functionality change rows visible. done follows:

  1. during initialization, set global ints mcurrentrow = 0 , mnumvisiblerows = 3. these define "view window".
  2. modify drawing code draw rows starting @ mcurrentrow , ending @ mcurrentrow + mnumvisiblerows. result of should ever see mnumvisiblerows rows, , group of rows see depends on set mcurrentrow to.
  3. add triangles right of grid drawing , have tap touch events in areas map increments/decrements of mcurrentrow. obviously, should not allow value go outside row count bounds.
  4. if want classy, draw line between triangles scroll area, , map touch events there newcurrentrow = (touch.y / canvas.height()) * boardsize; needs tweaking, idea.

this approach has downside of showing full set of rows @ time, scrolling wouldn't smooth. however, have complete control on canvas , draw, little more math implement smooth scrolling mechanism offset fractional row height in y-direction instead of whole rows.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -