Click here to Skip to main content
15,912,069 members
Home / Discussions / C#
   

C#

 
GeneralRe: Porting this to event-based? Pin
Nader Elshehabi24-Sep-06 14:54
Nader Elshehabi24-Sep-06 14:54 
GeneralRe: Porting this to event-based? Pin
Lord Kixdemp24-Sep-06 15:13
Lord Kixdemp24-Sep-06 15:13 
GeneralRe: Porting this to event-based? Pin
Nader Elshehabi24-Sep-06 15:30
Nader Elshehabi24-Sep-06 15:30 
GeneralRe: Porting this to event-based? Pin
Lord Kixdemp25-Sep-06 11:25
Lord Kixdemp25-Sep-06 11:25 
GeneralRe: Porting this to event-based? Pin
Nader Elshehabi25-Sep-06 11:44
Nader Elshehabi25-Sep-06 11:44 
GeneralRe: Porting this to event-based? Pin
Lord Kixdemp25-Sep-06 14:27
Lord Kixdemp25-Sep-06 14:27 
GeneralRe: Porting this to event-based? Pin
Nader Elshehabi25-Sep-06 14:36
Nader Elshehabi25-Sep-06 14:36 
GeneralRe: Porting this to event-based? Pin
Lord Kixdemp25-Sep-06 15:02
Lord Kixdemp25-Sep-06 15:02 
Oohh... So remove all the canRespond stuff? I made the loop like this, but it still runs slower on the 1.4GHz: Frown | :(

void Loop()
{
    while (On)
    {
        Render();

        // Sleep a bit so we don't use 100% CPU
        Thread.Sleep(10);
    }

    Quit(null, null);
}


Just in case, here's my Render() methamphetamethod (Laugh | :laugh: ):

void Render()
{
    if (lKey) mainPlayer.Pos.X -= (int)Game.WALK_SPEED;
    if (rKey) mainPlayer.Pos.X += (int)Game.WALK_SPEED;
    if (uKey) mainPlayer.Pos.Y -= (int)Game.WALK_SPEED;
    if (dKey) mainPlayer.Pos.Y += (int)Game.WALK_SPEED;

    // Check out-of-bounds for x-axis
    if (mainPlayer.Pos.X < 0)
        mainPlayer.Pos.X = 0;
    else if (mainPlayer.Pos.X > Game.SCR_WIDTH - Game.TILE_WIDTH - 1)
        mainPlayer.Pos.X = Game.SCR_WIDTH - Game.TILE_WIDTH - 1;

    // Check out-of-bounds for y-axis
    if (mainPlayer.Pos.Y < 0)
        mainPlayer.Pos.Y = 0;
    else if (mainPlayer.Pos.Y > Game.SCR_HEIGHT - Game.TILE_HEIGHT - 1)
        mainPlayer.Pos.Y = Game.SCR_HEIGHT - Game.TILE_HEIGHT - 1;

    // Place player
    Video.Screen.Blit(mainPlayer.Surf, mainPlayer.Pos);

    // Update whole screen
    Video.Screen.Update();

    return;
}


I read this page about timers:
http://msdn.microsoft.com/coding4fun/gamedevelopment/beginning/default.aspx
And it's what I was doing, but it only shows 3 lines of what's supposed to be longer... Frown | :( Anything wrong with Render() or something? Thanks! Wink | ;)

Windows Calculator told me I will die at 28. Frown | :(

GeneralRe: Porting this to event-based? Pin
Nader Elshehabi25-Sep-06 15:31
Nader Elshehabi25-Sep-06 15:31 
GeneralRe: Porting this to event-based? Pin
Lord Kixdemp26-Sep-06 14:55
Lord Kixdemp26-Sep-06 14:55 
AnswerRe: Porting this to event-based? Pin
Christian Graus24-Sep-06 15:12
protectorChristian Graus24-Sep-06 15:12 
GeneralRe: Porting this to event-based? Pin
Lord Kixdemp24-Sep-06 15:17
Lord Kixdemp24-Sep-06 15:17 
GeneralRe: Porting this to event-based? Pin
Christian Graus24-Sep-06 15:29
protectorChristian Graus24-Sep-06 15:29 
GeneralRe: Porting this to event-based? Pin
Lord Kixdemp25-Sep-06 8:14
Lord Kixdemp25-Sep-06 8:14 
Questionadd column to dataset Pin
Mohammed Elkholy24-Sep-06 10:39
Mohammed Elkholy24-Sep-06 10:39 
AnswerRe: add column to dataset Pin
Nader Elshehabi24-Sep-06 12:08
Nader Elshehabi24-Sep-06 12:08 
Question[Message Deleted] Pin
code_wiz24-Sep-06 8:06
code_wiz24-Sep-06 8:06 
AnswerRe: extracting a message value from LParam in Message in WndProc(...) Pin
Christian Graus24-Sep-06 11:58
protectorChristian Graus24-Sep-06 11:58 
QuestionRe: extracting a message value from LParam in Message in WndProc(...) Pin
Nader Elshehabi24-Sep-06 12:04
Nader Elshehabi24-Sep-06 12:04 
QuestionProblem getting serial port to open Pin
NYTSX24-Sep-06 7:50
NYTSX24-Sep-06 7:50 
AnswerRe: Problem getting serial port to open Pin
Ed.Poore24-Sep-06 8:23
Ed.Poore24-Sep-06 8:23 
GeneralRe: Problem getting serial port to open Pin
NYTSX25-Sep-06 0:59
NYTSX25-Sep-06 0:59 
GeneralRe: Problem getting serial port to open Pin
NYTSX25-Sep-06 1:12
NYTSX25-Sep-06 1:12 
GeneralRe: Problem getting serial port to open Pin
Ed.Poore25-Sep-06 1:19
Ed.Poore25-Sep-06 1:19 
QuestionSaving objects in Files Pin
ezazazel24-Sep-06 6:32
ezazazel24-Sep-06 6:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.