here - Rob Miles

birdsowlΛογισμικό & κατασκευή λογ/κού

2 Δεκ 2013 (πριν από 3 χρόνια και 8 μήνες)

109 εμφανίσεις

Display

480x800 QVGA

320x480 HVGA

Capacitive touch

4 or more contact points

Camera

5 mega pixels or more

Dedicated camera button

Hardware buttons

Start, Search, Back

Sensors

A
-
GPS, Accelerometer, Compass

GPU

DirectX 9 acceleration

CPU

ARMv7 Cortex/Scorpion or better

1G

Memory

256MB RAM or more

8GB Flash or more

Multimedia

Common detailed specs

Codec acceleration

Initialize
LoadContent
Update
Draw
// Game World

Texture2D

cloudTexture
;

Vector2

cloudPosition
;

protected

override

void

LoadContent
()

{


spriteBatch

=
new

SpriteBatch
(
GraphicsDevice
);



cloudPosition

=
new

Vector2
(0, 0);


cloudTexture

=
Content.Load
<
Texture2D
>(
"Cloud"
);

}

protected

override

void

Draw(
GameTime

gameTime
)

{


GraphicsDevice.Clear
(
Color
.CornflowerBlue
);



spriteBatch.Begin
();


spriteBatch.Draw
(
cloudTexture
,
cloudPosition
,
Color
.White
);


spriteBatch.End
();



base
.Draw
(
gameTime
);

}

DisplayOrientation
.Portrait

|


DisplayOrientation
.LandscapeLeft

|


DisplayOrientation
.LandscapeRight
;

new

EventHandler
<
EventArgs
>(
Window_OrientationChanged
);

...

void

Window_OrientationChanged
(
object

sender,
EventArgs

e)

{


if

(
Window.CurrentOrientation

==
DisplayOrientation
.Portrait
)


{



// gone to
portrait orientation


}

}

graphics.PreferredBackBufferWidth

= 240;

graphics.PreferredBackBufferHeight

= 400
;

true
;

protected

override

void

Initialize()

{


graphics.SupportedOrientations

=


DisplayOrientation
.LandscapeLeft

;


graphics.IsFullScreen

=
true
;


graphics.PreferredBackBufferWidth

=
800;


graphics.PreferredBackBufferHeight

=
480
;

}

Vector2

cloudSpeed

=
new

Vector2
(1.5f
, 0
);


protected

override

void

Update(
GameTime

gameTime
)

{


cloudPosition

+=
cloudSpeed
;



base
.Update
(
gameTime
);

}

interface

ISprite

{


void

Draw(
CloudGame

game);


void

Update(
CloudGame

game);

}


// Game World

List
<
ISprite
>
gameSprites

=
new

List
<
ISprite
>();

class

Cloud

:
CloudGame
.
ISprite

{


public

Texture2D

CloudTexture
;


public

Vector2

CloudPosition
;


public

Vector2

CloudSpeed
;



public

void

Draw(
CloudGame

game
) ...



public

void

Update(
CloudGame

game
) ...




public

Cloud(
Texture2D

inTexture
,
Vector2

inPosition
,


Vector2

inSpeed
) ...

}

Vector2

position =



new

Vector2
(
rand.Next
(
GraphicsDevice.Viewport.Width
),



rand.Next
(
GraphicsDevice.Viewport.Height
));


Vector2

speed =
new

Vector2
(
rand.Next
(0, 100) / 100f, 0);


Cloud

c =
new

Cloud
(
cloudTexture
, position, speed);


gameSprites.Add
(c
);

protected

override

void

Update(
GameTime

gameTime
)

{



foreach

(
ISprite

sprite
in

gameSprites
)



sprite.Update
(
this
);



base
.Update
(
gameTime
);

}

TouchCollection

Touches;


protected

override

void

Update(
GameTime

gameTime
)

{

TouchPanel
.GetState
();


foreach

(
ISprite

sprite
in

gameSprites
)


sprite.Update
(
this
);

}

foreach

(
TouchLocation

touch
in

game.Touches
)

{


if

(
touch.State

==
TouchLocationState
.Pressed
) {


if

(
CloudContains
(
touch.Position
) ) {




Burst =
true
;


return
;


}


}

}

public

bool

CloudContains
(
Vector2

pos
)

{



if

(
pos.X

<
CloudPosition.X
)
return

false
;


if

(
pos.X

> (
CloudPosition.X

+
CloudTexture.Width
))
return

false
;



if

(
pos.Y

<
CloudPosition.Y
)
return

false
;



if

(
pos.Y

> (
CloudPosition.Y

+
CloudTexture.Height
))
return

false
;


return

true
;

}

public

SoundEffect

CloudPopSound
;

...

SoundEffect

C
loudPopSound

=
Content.Load
<
SoundEffect
>(
"Pop"
);

...


TouchPanel
.EnabledGestures

=
GestureType
.Flick
;

while

(
TouchPanel
.IsGestureAvailable
)

{


GestureSample

gesture =
TouchPanel
.ReadGesture
();



if

(
gesture.GestureType

==
GestureType
.Flick
)


{


waterCloud.CloudSpeed

=
gesture.Delta

/ 100f;


}

}

using

Microsoft.Devices.Sensors
;

Accelerometer

accel
;

private

void

startAccelerometer
()

{


accel

=
new

Accelerometer
();



accel.ReadingChanged

+=
new
EventHandler



<
AccelerometerReadingEventArgs
>


(
accel_ReadingChanged
);


accel.Start
();

}

Vector3

accelReading
;

void

accel_ReadingChanged
(
object

sender,



AccelerometerReadingEventArgs

e)

{


lock

(
this
) {


accelReading.X

= (
float
)
e.X
;


accelReading.Y

= (
float
)
e.Y
;


accelReading.Z

= (
float
)
e.Z
;


}

}

Vector3

getAccReading
()

{


Vector3

result;



lock

(
this
) {


result =
new

Vector3
(
accelReading.X
,
accelReading.Y
,



accelReading.Z
);


}


return

result;

}

Vector3

acceleration =
game.getAccReading
();


CloudSpeed.X

-
=
acceleration.Y

* 0.1f;


CloudPosition

+=
CloudSpeed
;


void

wc_OpenReadCompleted
(
object

sender
,



OpenReadCompletedEventArgs

e)

{


if

(
e.Error

==
null
)


{


mapImage

=
Texture2D
.FromStream(
graphics.GraphicsDevice
,


e.Result
);


}

}

http://create.msdn.com
http://
pubcenter.microsoft.com
http
://robmiles.com