std::string package_symbol_name;
std::string package_name;
std::string package_version;
-
+
+int screen_width = SCREEN_WIDTH;
+int screen_height = SCREEN_HEIGHT;
+
JoystickKeymap::JoystickKeymap()
{
a_button = 0;
extern MouseCursor * mouse_cursor;
+#define SCREEN_WIDTH 800
+#define SCREEN_HEIGHT 600
+
extern bool use_gl;
extern bool use_joystick;
extern bool use_fullscreen;
+ extern int screen_width;
+ extern int screen_height;
extern bool debug_mode;
extern bool show_fps;
extern bool debug_grid;
glViewport(0, 0, screen->w, screen->h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- glOrtho(0, screen->w, screen->h, 0, -1.0, 1.0);
+ glOrtho(0, 800, 600, 0, -1.0, 1.0);
+ //glOrtho(0, 800SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
{
use_fullscreen = false;
}
+ else if (strcmp(argv[i], "--geometry") == 0 ||
+ strcmp(argv[i], "-g") == 0)
+ {
+ assert(i+1 < argc);
+ if (sscanf(argv[++i],
+ "%dx%d", &screen_width, &screen_height) != 2)
+ {
+ puts("Warning: Invalid geometry spec, should be \"WIDTHxHEIGHT\"");
+ }
+ }
else if (strcmp(argv[i], "--joystick") == 0 || strcmp(argv[i], "-j") == 0)
{
assert(i+1 < argc);
" --opengl If OpenGL support was compiled in, this will tell\n"
" SuperTux to make use of it.\n"
" --sdl Use the SDL software graphical renderer\n"
+ " --geometry WIDTHxHEIGHT Run SuperTux in the given resolution\n"
"\n"
"Sound Options:\n"
" --disable-sound If sound support was compiled in, this will\n"
/* Display the usage message: */
- fprintf(fi, _("Usage: %s [--fullscreen] [--opengl] [--disable-sound] [--disable-music] [--debug] | [--usage | --help | --version] [--leveleditor] [--worldmap] [--flip-levels] FILENAME\n"),
+ fprintf(fi, _("Usage: %s [--fullscreen] [--opengl] [--geometry WIDTHxHEIGHT] [--disable-sound] [--disable-music] [--debug] | [--usage | --help | --version] [--leveleditor] [--worldmap] [--flip-levels] FILENAME\n"),
prog);
// TODO make sure this formula is good
float distance
= pos2.x- pos.x;
- int loud = int(255.0/float(screen->w*2) * fabsf(distance));
+ int loud = int(255.0/float(SCREEN_WIDTH*2) * fabsf(distance));
if(loud > 255)
return;
if(state == BT_SHOW_INFO)
{
Vector offset;
- if(pos.x + tanslation.x < 100 && pos.y + tanslation.y > screen->h - 20)
+ if(pos.x + tanslation.x < 100 && pos.y + tanslation.y > SCREEN_HEIGHT - 20)
offset = Vector(size.x, - 10);
else if(pos.x + tanslation.x < 100)
offset = Vector(size.x, 0);
if(mouse_left_button)
{
- pos.x += event.motion.xrel;
- pos.y += event.motion.yrel;
+ pos.x += int(event.motion.xrel * float(SCREEN_WIDTH)/screen->w);
+ pos.y += int(event.motion.yrel * float(SCREEN_HEIGHT)/screen->h);
caught_event = true;
}
if(event.button.x > pos.x-12 && event.button.x < pos.x+16 + buttons_box.x*buttons_size.x &&
delete_character = 0;
mn_input_char = '\0';
- pos_x = screen->w/2;
- pos_y = screen->h/2;
+ pos_x = SCREEN_WIDTH/2;
+ pos_y = SCREEN_HEIGHT/2;
arrange_left = 0;
active_item = 0;
effect.init(false);
case MN_DEACTIVE:
{
context.draw_text(deactive_font, pitem.text,
- Vector(screen->w/2, y_pos - int(deactive_font->get_height()/2)),
+ Vector(SCREEN_WIDTH/2, y_pos - int(deactive_font->get_height()/2)),
CENTER_ALLIGN, LAYER_GUI);
break;
}
case MN_LABEL:
{
context.draw_text(label_font, pitem.text,
- Vector(screen->w/2, y_pos - int(label_font->get_height()/2)),
+ Vector(SCREEN_WIDTH/2, y_pos - int(label_font->get_height()/2)),
CENTER_ALLIGN, LAYER_GUI);
break;
}
case MN_CONTROLFIELD_JS:
{
int width = text_width + input_width + 5;
- int text_pos = screen->w/2 - width/2;
+ int text_pos = SCREEN_WIDTH/2 - width/2;
int input_pos = text_pos + text_width + 10;
context.draw_filled_rect(
Color(0,0,0,128), LAYER_GUI - 5);
context.draw_text(text_font, pitem.list[pitem.selected],
- Vector(screen->w/2 + text_pos, y_pos - int(text_font->get_height()/2)),
+ Vector(SCREEN_WIDTH/2 + text_pos, y_pos - int(text_font->get_height()/2)),
CENTER_ALLIGN, LAYER_GUI);
context.draw_text(text_font, pitem.text,
- Vector(screen->w/2 + list_pos_2/2, y_pos - int(text_font->get_height()/2)),
+ Vector(SCREEN_WIDTH/2 + list_pos_2/2, y_pos - int(text_font->get_height()/2)),
CENTER_ALLIGN, LAYER_GUI);
break;
}
case MN_BACK:
{
context.draw_text(text_font, pitem.text,
- Vector(screen->w/2, y_pos - int(text_font->get_height()/2)),
+ Vector(SCREEN_WIDTH/2, y_pos - int(text_font->get_height()/2)),
CENTER_ALLIGN, LAYER_GUI);
context.draw_surface(back,
Vector(x_pos + text_width/2 + 16, y_pos - 8),
case MN_TOGGLE:
{
context.draw_text(text_font, pitem.text,
- Vector(screen->w/2, y_pos - (text_font->get_height()/2)),
+ Vector(SCREEN_WIDTH/2, y_pos - (text_font->get_height()/2)),
CENTER_ALLIGN, LAYER_GUI);
if(pitem.toggled)
}
case MN_ACTION:
context.draw_text(text_font, pitem.text,
- Vector(screen->w/2, y_pos - int(text_font->get_height()/2)),
+ Vector(SCREEN_WIDTH/2, y_pos - int(text_font->get_height()/2)),
CENTER_ALLIGN, LAYER_GUI);
break;
case MN_GOTO:
context.draw_text(text_font, pitem.text,
- Vector(screen->w/2, y_pos - int(text_font->get_height()/2)),
+ Vector(SCREEN_WIDTH/2, y_pos - int(text_font->get_height()/2)),
CENTER_ALLIGN, LAYER_GUI);
break;
}
case SDL_MOUSEBUTTONDOWN:
{
- int x = event.motion.x;
- int y = event.motion.y;
+ int x = int(event.motion.x * float(SCREEN_WIDTH)/screen->w);
+ int y = int(event.motion.y * float(SCREEN_HEIGHT)/screen->h);
if(x > pos_x - get_width()/2 &&
x < pos_x + get_width()/2 &&
case SDL_MOUSEMOTION:
{
- int x = event.motion.x;
- int y = event.motion.y;
+ int x = int(event.motion.x * float(SCREEN_WIDTH)/screen->w);
+ int y = int(event.motion.y * float(SCREEN_HEIGHT)/screen->h);
if(x > pos_x - get_width()/2 &&
x < pos_x + get_width()/2 &&
#include <config.h>
+#include "app/globals.h"
#include "video/drawing_context.h"
#include "gui/mousecursor.h"
int x,y,w,h;
Uint8 ispressed = SDL_GetMouseState(&x,&y);
+
+ x = int(x * float(SCREEN_WIDTH)/screen->w);
+ y = int(y * float(SCREEN_HEIGHT)/screen->h);
+
w = cursor->w / tot_frames;
h = cursor->h / MC_STATES_NB;
if(ispressed &SDL_BUTTON(1) || ispressed &SDL_BUTTON(2))
request.type = SURFACE;
request.pos = transform.apply(position);
- if(request.pos.x >= screen->w || request.pos.y >= screen->h
+ if(request.pos.x >= SCREEN_WIDTH || request.pos.y >= SCREEN_HEIGHT
|| request.pos.x + surface->w < 0 || request.pos.y + surface->h < 0)
return;
DrawingContext::draw_center_text(const Font* font, const std::string& text,
const Vector& position, int layer, uint32_t drawing_effect)
{
- draw_text(font, text, Vector(position.x + screen->w/2, position.y),
+ draw_text(font, text, Vector(position.x + SCREEN_WIDTH/2, position.y),
CENTER_ALLIGN, layer, drawing_effect);
}
glBegin(GL_QUADS);
glColor3ub(top.red, top.green, top.blue);
glVertex2f(0, 0);
- glVertex2f(screen->w, 0);
+ glVertex2f(SCREEN_WIDTH, 0);
glColor3ub(bottom.red, bottom.green, bottom.blue);
- glVertex2f(screen->w, screen->h);
- glVertex2f(0, screen->h);
+ glVertex2f(SCREEN_WIDTH, SCREEN_HEIGHT);
+ glVertex2f(0, SCREEN_HEIGHT);
glEnd();
}
else
#endif
if(&top == &bottom)
{
- fillrect(0, 0, screen->w, screen->h, top.red, top.green, top.blue);
+ fillrect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, top.red, top.green, top.blue);
}
else
{
- float redstep = (float(bottom.red)-float(top.red)) / float(screen->h);
- float greenstep = (float(bottom.green)-float(top.green)) / float(screen->h);
- float bluestep = (float(bottom.blue) - float(top.blue)) / float(screen->h);
+ float redstep = (float(bottom.red)-float(top.red)) / float(SCREEN_HEIGHT);
+ float greenstep = (float(bottom.green)-float(top.green)) / float(SCREEN_HEIGHT);
+ float bluestep = (float(bottom.blue) - float(top.blue)) / float(SCREEN_HEIGHT);
- for(float y = 0; y < screen->h; y += 2)
- fillrect(0, (int)y, screen->w, 2,
+ for(float y = 0; y < SCREEN_HEIGHT; y += 2)
+ fillrect(0, (int)y, SCREEN_WIDTH, 2,
int(float(top.red) + redstep * y),
int(float(top.green) + greenstep * y),
int(float(top.blue) + bluestep * y), 255);
uint32_t drawing_effect = NONE_EFFECT);
/// Draws text on screen center (feed Vector.x with a 0).
- /// This is the same as draw_text() with a screen->w/2 position and
+ /// This is the same as draw_text() with a SCREEN_WIDTH/2 position and
/// alignment set to LEFT_ALLIGN
void draw_center_text(const Font* font, const std::string& text,
const Vector& position, int layer,
}
}
- if(!(x < 0 || y < 0 || x > screen->w || y > screen->h))
+ if(!(x < 0 || y < 0 || x > SCREEN_WIDTH || y > SCREEN_HEIGHT))
putpixel(screen, x, y, pixel);
if ( SDL_MUSTLOCK(screen) )
while(alpha > 0)
{
alpha -= alpha_inc;
- fillrect(0, 0, screen->w, screen->h, 0,0,0, (int)alpha_inc); // left side
+ fillrect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0,0,0, (int)alpha_inc); // left side
DrawingContext context; // ugly...
context.do_drawing();
SDL_Delay(int(LOOP_DELAY));
}
- fillrect(0, 0, screen->w, screen->h, 0, 0, 0, 255);
+ fillrect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0, 255);
}
void SuperTux::shrink_fade(const Vector& point, int fade_time)
{
float left_inc = point.x / ((float)fade_time / LOOP_DELAY);
- float right_inc = (screen->w - point.x) / ((float)fade_time / LOOP_DELAY);
+ float right_inc = (SCREEN_WIDTH - point.x) / ((float)fade_time / LOOP_DELAY);
float up_inc = point.y / ((float)fade_time / LOOP_DELAY);
- float down_inc = (screen->h - point.y) / ((float)fade_time / LOOP_DELAY);
+ float down_inc = (SCREEN_HEIGHT - point.y) / ((float)fade_time / LOOP_DELAY);
float left_cor = 0, right_cor = 0, up_cor = 0, down_cor = 0;
- while(left_cor < point.x && right_cor < screen->w - point.x &&
- up_cor < point.y && down_cor < screen->h - point.y)
+ while(left_cor < point.x && right_cor < SCREEN_WIDTH - point.x &&
+ up_cor < point.y && down_cor < SCREEN_HEIGHT - point.y)
{
left_cor += left_inc;
right_cor += right_inc;
up_cor += up_inc;
down_cor += down_inc;
- fillrect(0, 0, left_cor, screen->h, 0,0,0); // left side
- fillrect(screen->w - right_cor, 0, right_cor, screen->h, 0,0,0); // right side
- fillrect(0, 0, screen->w, up_cor, 0,0,0); // up side
- fillrect(0, screen->h - down_cor, screen->w, down_cor+1, 0,0,0); // down side
+ fillrect(0, 0, left_cor, SCREEN_HEIGHT, 0,0,0); // left side
+ fillrect(SCREEN_WIDTH - right_cor, 0, right_cor, SCREEN_HEIGHT, 0,0,0); // right side
+ fillrect(0, 0, SCREEN_WIDTH, up_cor, 0,0,0); // up side
+ fillrect(0, SCREEN_HEIGHT - down_cor, SCREEN_WIDTH, down_cor+1, 0,0,0); // down side
DrawingContext context; // ugly...
context.do_drawing();
}
}
-// context.draw_text(gold_text, level->get_name(), Vector(screen->w/2, 160),
+// context.draw_text(gold_text, level->get_name(), Vector(SCREEN_WIDTH/2, 160),
// CENTER_ALLIGN, LAYER_FOREGROUND1);
context.draw_center_text(gold_text, level->get_name(), Vector(0, 160),
LAYER_FOREGROUND1);
sprintf(str, "TUX x %d", player_status.lives);
- context.draw_text(white_text, str, Vector(screen->w/2, 210),
+ context.draw_text(white_text, str, Vector(SCREEN_WIDTH/2, 210),
CENTER_ALLIGN, LAYER_FOREGROUND1);
if((level->get_author().size()) && (level->get_author() != "SuperTux Team"))
//TODO make author check case/blank-insensitive
context.draw_text(white_small_text,
std::string(_("contributed by ")) + level->get_author(),
- Vector(screen->w/2, 350), CENTER_ALLIGN, LAYER_FOREGROUND1);
+ Vector(SCREEN_WIDTH/2, 350), CENTER_ALLIGN, LAYER_FOREGROUND1);
if(best_level_statistics != NULL)
snprintf(buf, sizeof(buf), "P: %4.1f,%4.1f",
tux.get_pos().x, tux.get_pos().y);
context->draw_text(white_text, buf,
- Vector(0, screen->h - white_text->get_height()),
+ Vector(0, SCREEN_HEIGHT - white_text->get_height()),
LEFT_ALLIGN, LAYER_FOREGROUND1);
context->do_drawing();
SDL_Delay(1000);
if(compare_last(last_keys, "gotoend")) {
// goes to the end of the level
tux.move(Vector(
- (currentsector->solids->get_width()*32) - (screen->w*2), 0));
+ (currentsector->solids->get_width()*32) - (SCREEN_WIDTH*2), 0));
currentsector->camera->reset(
Vector(tux.get_pos().x, tux.get_pos().y));
last_keys.clear();
void
GameSession::draw_pause()
{
- int x = screen->h / 20;
+ int x = SCREEN_HEIGHT / 20;
for(int i = 0; i < x; ++i) {
context->draw_filled_rect(
- Vector(i % 2 ? (pause_menu_frame * i)%screen->w :
- -((pause_menu_frame * i)%screen->w)
- ,(i*20+pause_menu_frame)%screen->h),
- Vector(screen->w,10),
+ Vector(i % 2 ? (pause_menu_frame * i)%SCREEN_WIDTH :
+ -((pause_menu_frame * i)%SCREEN_WIDTH)
+ ,(i*20+pause_menu_frame)%SCREEN_HEIGHT),
+ Vector(SCREEN_WIDTH,10),
Color(20,20,20, rand() % 20 + 1), LAYER_FOREGROUND1+1);
}
context->draw_filled_rect(
- Vector(0,0), Vector(screen->w, screen->h),
+ Vector(0,0), Vector(SCREEN_WIDTH, SCREEN_HEIGHT),
Color(rand() % 50, rand() % 50, rand() % 50, 128), LAYER_FOREGROUND1);
context->draw_text(blue_text, _("PAUSE - Press 'P' To Play"),
- Vector(screen->w/2, 230), CENTER_ALLIGN, LAYER_FOREGROUND1+2);
+ Vector(SCREEN_WIDTH/2, 230), CENTER_ALLIGN, LAYER_FOREGROUND1+2);
const char* str1 = _("Playing: ");
const char* str2 = level->get_name().c_str();
context->draw_text(blue_text, str1,
- Vector((screen->w - (blue_text->get_text_width(str1) + white_text->get_text_width(str2)))/2, 340),
+ Vector((SCREEN_WIDTH - (blue_text->get_text_width(str1) + white_text->get_text_width(str2)))/2, 340),
LEFT_ALLIGN, LAYER_FOREGROUND1+2);
context->draw_text(white_text, str2,
- Vector(((screen->w - (blue_text->get_text_width(str1) + white_text->get_text_width(str2)))/2)+blue_text->get_text_width(str1), 340),
+ Vector(((SCREEN_WIDTH - (blue_text->get_text_width(str1) + white_text->get_text_width(str2)))/2)+blue_text->get_text_width(str1), 340),
LEFT_ALLIGN, LAYER_FOREGROUND1+2);
}
}
if(time_left.get_timeleft() < 0) {
- context.draw_text(white_text, _("TIME's UP"), Vector(screen->w/2, 0),
+ context.draw_text(white_text, _("TIME's UP"), Vector(SCREEN_WIDTH/2, 0),
CENTER_ALLIGN, LAYER_FOREGROUND1);
} else if (time_left.get_timeleft() > TIME_WARNING
|| int(global_time * 2.5) % 2) {
sprintf(str, " %d", int(time_left.get_timeleft()));
context.draw_text(white_text, _("TIME"),
- Vector(screen->w/2, 0), CENTER_ALLIGN, LAYER_FOREGROUND1);
+ Vector(SCREEN_WIDTH/2, 0), CENTER_ALLIGN, LAYER_FOREGROUND1);
context.draw_text(gold_text, str,
- Vector(screen->w/2 + 4*16, 0), CENTER_ALLIGN, LAYER_FOREGROUND1);
+ Vector(SCREEN_WIDTH/2 + 4*16, 0), CENTER_ALLIGN, LAYER_FOREGROUND1);
}
sprintf(str, " %d", player_status.distros);
context.draw_text(white_text, _("COINS"),
- Vector(screen->w - white_text->get_text_width(_("COINS"))-white_text->get_text_width(" 99"), 0),
+ Vector(SCREEN_WIDTH - white_text->get_text_width(_("COINS"))-white_text->get_text_width(" 99"), 0),
LEFT_ALLIGN, LAYER_FOREGROUND1);
context.draw_text(gold_text, str,
- Vector(screen->w - gold_text->get_text_width(" 99"), 0),LEFT_ALLIGN, LAYER_FOREGROUND1);
+ Vector(SCREEN_WIDTH - gold_text->get_text_width(" 99"), 0),LEFT_ALLIGN, LAYER_FOREGROUND1);
if (player_status.lives >= 5)
{
sprintf(str, "%dx", player_status.lives);
- float x = screen->w - gold_text->get_text_width(str) - tux_life->w;
+ float x = SCREEN_WIDTH - gold_text->get_text_width(str) - tux_life->w;
context.draw_text(gold_text, str, Vector(x, 20), LEFT_ALLIGN, LAYER_FOREGROUND1);
- context.draw_surface(tux_life, Vector(screen->w - 16, 20),
+ context.draw_surface(tux_life, Vector(SCREEN_WIDTH - 16, 20),
LAYER_FOREGROUND1);
}
else
{
for(int i= 0; i < player_status.lives; ++i)
context.draw_surface(tux_life,
- Vector(screen->w - tux_life->w*4 +(tux_life->w*i), 20),
+ Vector(SCREEN_WIDTH - tux_life->w*4 +(tux_life->w*i), 20),
LAYER_FOREGROUND1);
}
context.draw_text(white_text, _("LIVES"),
- Vector(screen->w - white_text->get_text_width(_("LIVES")) - white_text->get_text_width(" 99"), 20),
+ Vector(SCREEN_WIDTH - white_text->get_text_width(_("LIVES")) - white_text->get_text_width(" 99"), 20),
LEFT_ALLIGN, LAYER_FOREGROUND1);
if(show_fps)
{
sprintf(str, "%2.1f", fps_fps);
context.draw_text(white_text, "FPS",
- Vector(screen->w - white_text->get_text_width("FPS "), 40),
+ Vector(SCREEN_WIDTH - white_text->get_text_width("FPS "), 40),
LEFT_ALLIGN, LAYER_FOREGROUND1);
context.draw_text(gold_text, str,
- Vector(screen->w-4*16, 40), LEFT_ALLIGN, LAYER_FOREGROUND1);
+ Vector(SCREEN_WIDTH-4*16, 40), LEFT_ALLIGN, LAYER_FOREGROUND1);
}
}
}
}
- context.draw_text(blue_text, _("Result:"), Vector(screen->w/2, 200),
+ context.draw_text(blue_text, _("Result:"), Vector(SCREEN_WIDTH/2, 200),
CENTER_ALLIGN, LAYER_FOREGROUND1);
sprintf(str, _("SCORE: %d"), global_stats.get_points(SCORE_STAT));
- context.draw_text(gold_text, str, Vector(screen->w/2, 224), CENTER_ALLIGN, LAYER_FOREGROUND1);
+ context.draw_text(gold_text, str, Vector(SCREEN_WIDTH/2, 224), CENTER_ALLIGN, LAYER_FOREGROUND1);
sprintf(str, _("COINS: %d"), player_status.distros);
- context.draw_text(gold_text, str, Vector(screen->w/2, 256), CENTER_ALLIGN, LAYER_FOREGROUND1);
+ context.draw_text(gold_text, str, Vector(SCREEN_WIDTH/2, 256), CENTER_ALLIGN, LAYER_FOREGROUND1);
context.do_drawing();
fadeout(256);
DrawingContext context;
context.draw_text(white_text, "Loading...",
- Vector(screen->w/2, screen->h/2), CENTER_ALLIGN, LAYER_FOREGROUND1);
+ Vector(SCREEN_WIDTH/2, SCREEN_HEIGHT/2), CENTER_ALLIGN, LAYER_FOREGROUND1);
context.do_drawing();
WorldMapNS::WorldMap worldmap;
/* Creating button groups */
load_buttons_gfx();
- tiles_board = new ButtonGroup(Vector(screen->w - 140, 100),
+ tiles_board = new ButtonGroup(Vector(SCREEN_WIDTH - 140, 100),
Vector(32,32), Vector(4,8));
tiles_board->add_button(Button(img_rubber_bt, _("Eraser"), SDLKey(SDLK_DELETE)), 0);
SDLKey(SDLK_1+id)), id++);
}
- tiles_layer = new ButtonGroup(Vector(12, screen->h-64), Vector(80,20), Vector(1,3));
+ tiles_layer = new ButtonGroup(Vector(12, SCREEN_HEIGHT-64), Vector(80,20), Vector(1,3));
tiles_layer->add_button(Button(img_foreground_bt, _("Edtit foreground tiles"),
SDLK_F10), LAYER_FOREGROUNDTILES);
tiles_layer->add_button(Button(img_interactive_bt, _("Edit interactive tiles"),
tiles_layer->add_button(Button(img_background_bt, _("Edit background tiles"),
SDLK_F12), LAYER_BACKGROUNDTILES);
- level_options = new ButtonGroup(Vector(screen->w-164, screen->h-36), Vector(32,32), Vector(5,1));
+ level_options = new ButtonGroup(Vector(SCREEN_WIDTH-164, SCREEN_HEIGHT-36), Vector(32,32), Vector(5,1));
level_options->add_pair_of_buttons(Button(img_next_sector_bt, _("Next sector"), SDLKey(0)), BT_NEXT_SECTOR,
Button(img_previous_sector_bt, _("Prevous sector"), SDLKey(0)), BT_PREVIOUS_SECTOR);
level_options->add_pair_of_buttons(Button(img_next_level_bt, _("Next level"), SDLKey(0)), BT_NEXT_LEVEL,
scroll.x = 0;
break;
case SDLK_END:
- scroll.x = sector->solids->get_height()*32 - screen->w;
+ scroll.x = sector->solids->get_height()*32 - SCREEN_WIDTH;
break;
case SDLK_LEFT:
scroll.x -= 80;
float width = sector->solids->get_width() * 32;
float height = sector->solids->get_height() * 32;
- if(scroll.x < -screen->w/2)
- scroll.x = -screen->w/2;
- if(scroll.x > width - screen->w/2)
- scroll.x = width - screen->w/2;
- if(scroll.y < -screen->h/2)
- scroll.y = -screen->h/2;
- if(scroll.y > height - screen->h/2)
- scroll.y = height - screen->h/2;
+ if(scroll.x < -SCREEN_WIDTH/2)
+ scroll.x = -SCREEN_WIDTH/2;
+ if(scroll.x > width - SCREEN_WIDTH/2)
+ scroll.x = width - SCREEN_WIDTH/2;
+ if(scroll.y < -SCREEN_HEIGHT/2)
+ scroll.y = -SCREEN_HEIGHT/2;
+ if(scroll.y > height - SCREEN_HEIGHT/2)
+ scroll.y = height - SCREEN_HEIGHT/2;
// set camera translation, since BadGuys like it
sector->camera->set_scrolling((int)scroll.x, (int)scroll.y);
mouse_cursor->draw(context);
// draw a filled background
- context.draw_filled_rect(Vector(0,0), Vector(screen->w,screen->h), Color(60,60,60), LAYER_BACKGROUND0-1);
+ context.draw_filled_rect(Vector(0,0), Vector(SCREEN_WIDTH,SCREEN_HEIGHT), Color(60,60,60), LAYER_BACKGROUND0-1);
if(level_name_timer.check())
{
if(level_name_timer.get_timeleft() < FADING_TIME)
context.set_alpha(int(level_name_timer.get_timeleft() * 255 / FADING_TIME));
- context.draw_text(gold_text, level->name, Vector(screen->w/2, 30), CENTER_ALLIGN, LAYER_GUI);
+ context.draw_text(gold_text, level->name, Vector(SCREEN_WIDTH/2, 30), CENTER_ALLIGN, LAYER_GUI);
if(level_nb != -1)
{
char str[128];
sprintf(str, "%i/%i", level_nb+1, level_subset->get_num_levels());
- context.draw_text(gold_text, str, Vector(screen->w/2, 50), CENTER_ALLIGN, LAYER_GUI);
+ context.draw_text(gold_text, str, Vector(SCREEN_WIDTH/2, 50), CENTER_ALLIGN, LAYER_GUI);
}
context.pop_transform();
if(show_grid)
{
- for(int x = 0; x < screen->w / (32*zoom); x++)
+ for(int x = 0; x < SCREEN_WIDTH / (32*zoom); x++)
{
int pos = (int)(x*32*zoom) - ((int)scroll.x % 32);
- context.draw_filled_rect(Vector (pos, 0), Vector(1, screen->h),
+ context.draw_filled_rect(Vector (pos, 0), Vector(1, SCREEN_HEIGHT),
Color(225, 225, 225), LAYER_GUI-50);
}
- for(int y = 0; y < screen->h / (32*zoom); y++)
+ for(int y = 0; y < SCREEN_HEIGHT / (32*zoom); y++)
{
int pos = (int)(y*32*zoom) - ((int)scroll.y % 32);
- context.draw_filled_rect(Vector (0, pos), Vector(screen->w, 1),
+ context.draw_filled_rect(Vector (0, pos), Vector(SCREEN_WIDTH, 1),
Color(225, 225, 225), LAYER_GUI-50);
}
}
context.pop_transform();
}
else
- context.draw_filled_rect(Vector(0,0), Vector(screen->w,screen->h),Color(0,0,0), LAYER_BACKGROUND0);
+ context.draw_filled_rect(Vector(0,0), Vector(SCREEN_WIDTH,SCREEN_HEIGHT),Color(0,0,0), LAYER_BACKGROUND0);
context.do_drawing();
}
{
draw(context);
- context.draw_text(blue_text, _("- Level Editor's Help -"), Vector(screen->w/2, 60), CENTER_ALLIGN, LAYER_GUI);
+ context.draw_text(blue_text, _("- Level Editor's Help -"), Vector(SCREEN_WIDTH/2, 60), CENTER_ALLIGN, LAYER_GUI);
context.draw_text(white_small_text, *text[i], Vector(20, 120), LEFT_ALLIGN, LAYER_GUI);
sprintf(str,_("Press any key to continue - Page %d/%d"), i+1, sizeof(text) / sizeof(text[0]));
- context.draw_text(gold_text, str, Vector(screen->w/2, screen->h-60), CENTER_ALLIGN, LAYER_GUI);
+ context.draw_text(gold_text, str, Vector(SCREEN_WIDTH/2, SCREEN_HEIGHT-60), CENTER_ALLIGN, LAYER_GUI);
context.do_drawing();
if(use_gl != options_menu->isToggled(MNID_OPENGL))
{
use_gl = !use_gl;
- Setup::video(screen->w,screen->h);
+ Setup::video(SCREEN_WIDTH,SCREEN_HEIGHT);
}
#else
options_menu->get_item_by_id(MNID_OPENGL).toggled = false;
if(use_fullscreen != options_menu->isToggled(MNID_FULLSCREEN))
{
use_fullscreen = !use_fullscreen;
- Setup::video(screen->w,screen->h);
+ Setup::video(SCREEN_WIDTH,SCREEN_HEIGHT);
}
break;
case MNID_SOUND:
contrib_subset_menu = new Menu();
worldmap_menu = new Menu();
- main_menu->set_pos(screen->w/2, 335);
+ main_menu->set_pos(SCREEN_WIDTH/2, 335);
main_menu->additem(MN_GOTO, _("Start Game"),0,load_game_menu, MNID_STARTGAME);
main_menu->additem(MN_GOTO, _("Contrib Levels"),0,contrib_menu, MNID_LEVELS_CONTRIB);
main_menu->additem(MN_GOTO, _("Options"),0,options_menu, MNID_OPTIONMENU);
gradient_bottom = bottom;
delete image;
- image = new Surface(top, bottom, screen->w, screen->h);
+ image = new Surface(top, bottom, SCREEN_WIDTH, SCREEN_HEIGHT);
}
void
int sy = int(-context.get_translation().y * speed) % image->h - image->h;
context.push_transform();
context.set_translation(Vector(0, 0));
- for(int x = sx; x < screen->w; x += image->w)
- for(int y = sy; y < screen->h; y += image->h)
+ for(int x = sx; x < SCREEN_WIDTH; x += image->w)
+ for(int y = sy; y < SCREEN_HEIGHT; y += image->h)
context.draw_surface(image, Vector(x, y), layer);
context.pop_transform();
}
float scroll_y =
Sector::current()->camera->get_translation().y;
if (get_pos().x < scroll_x ||
- get_pos().x > scroll_x + screen->w ||
+ get_pos().x > scroll_x + SCREEN_WIDTH ||
// get_pos().y < scroll_y ||
- get_pos().y > scroll_y + screen->h ||
+ get_pos().y > scroll_y + SCREEN_HEIGHT ||
life_count <= 0) {
remove_me();
return;
void
Camera::reset(const Vector& tuxpos)
{
- translation.x = tuxpos.x - screen->w/3 * 2;
- translation.y = tuxpos.y - screen->h/2;
+ translation.x = tuxpos.x - SCREEN_WIDTH/3 * 2;
+ translation.y = tuxpos.y - SCREEN_HEIGHT/2;
keep_in_bounds();
}
float height = sector->solids->get_height() * 32;
// don't scroll before the start or after the level's end
- if(translation.y > height - screen->h)
- translation.y = height - screen->h;
+ if(translation.y > height - SCREEN_HEIGHT)
+ translation.y = height - SCREEN_HEIGHT;
if(translation.y < 0)
translation.y = 0;
- if(translation.x > width - screen->w)
- translation.x = width - screen->w;
+ if(translation.x > width - SCREEN_WIDTH)
+ translation.x = width - SCREEN_WIDTH;
if(translation.x < 0)
translation.x = 0;
}
target_y = player->get_bbox().p2.y;
// delta_y is the distance we'd have to travel to directly reach target_y
- float delta_y = translation.y - (target_y - screen->h/2);
+ float delta_y = translation.y - (target_y - SCREEN_HEIGHT/2);
// speed is the speed the camera would need to reach target_y in this frame
float speed_y = delta_y / elapsed_time;
|| (player->dir == ::RIGHT && scrollchange == LEFT))
scrollchange = NONE;
// when in left 1/3rd of screen scroll left
- if(player->get_bbox().get_middle().x < translation.x + screen->w/3 - 16
+ if(player->get_bbox().get_middle().x < translation.x + SCREEN_WIDTH/3 - 16
&& do_backscrolling)
scrollchange = LEFT;
// scroll right when in right 1/3rd of screen
- else if(player->get_bbox().get_middle().x > translation.x + screen->w/3*2+16)
+ else if(player->get_bbox().get_middle().x > translation.x + SCREEN_WIDTH/3*2+16)
scrollchange = RIGHT;
// calculate our scroll target depending on scroll mode
float target_x;
if(scrollchange == LEFT)
- target_x = player->get_bbox().get_middle().x - screen->w/3*2;
+ target_x = player->get_bbox().get_middle().x - SCREEN_WIDTH/3*2;
else if(scrollchange == RIGHT)
- target_x = player->get_bbox().get_middle().x - screen->w/3;
+ target_x = player->get_bbox().get_middle().x - SCREEN_WIDTH/3;
else
target_x = translation.x;
if(timer.check()) {
Sector* sector = Sector::current();
Vector pos = sector->camera->get_translation();
- pos += Vector(screen->w * ((float) rand() / RAND_MAX),
- screen->h/2 * ((float) rand() / RAND_MAX));
+ pos += Vector(SCREEN_WIDTH * ((float) rand() / RAND_MAX),
+ SCREEN_HEIGHT/2 * ((float) rand() / RAND_MAX));
int red = rand() % 255;
int green = rand() % red;
(*i)->vel.x += accel.x * elapsed_time;
(*i)->vel.y += accel.y * elapsed_time;
- if((*i)->pos.x < camera.x || (*i)->pos.x > screen->w + camera.x ||
- (*i)->pos.y < camera.y || (*i)->pos.y > screen->h + camera.y) {
+ if((*i)->pos.x < camera.x || (*i)->pos.x > SCREEN_WIDTH + camera.x ||
+ (*i)->pos.y < camera.y || (*i)->pos.y > SCREEN_HEIGHT + camera.y) {
delete (*i);
i = particles.erase(i);
} else {
ParticleSystem::ParticleSystem()
{
- virtual_width = screen->w;
- virtual_height = screen->h;
+ virtual_width = SCREEN_WIDTH;
+ virtual_height = SCREEN_HEIGHT;
layer = LAYER_BACKGROUND1;
}
pos.y = fmodf(particle->pos.y - scrolly, virtual_height);
if(pos.y < 0) pos.y += virtual_height;
- if(pos.x > screen->w) pos.x -= virtual_width;
- if(pos.y > screen->h) pos.y -= virtual_height;
+ if(pos.x > SCREEN_WIDTH) pos.x -= virtual_width;
+ if(pos.y > SCREEN_HEIGHT) pos.y -= virtual_height;
context.draw_surface(particle->texture, pos, layer);
}
snowimages[1] = new Surface(datadir+"/images/shared/snow1.png", true);
snowimages[2] = new Surface(datadir+"/images/shared/snow2.png", true);
- virtual_width = screen->w * 2;
+ virtual_width = SCREEN_WIDTH * 2;
// create some random snowflakes
size_t snowflakecount = size_t(virtual_width/10.0);
for(size_t i=0; i<snowflakecount; ++i) {
SnowParticle* particle = new SnowParticle;
particle->pos.x = rand() % int(virtual_width);
- particle->pos.y = rand() % screen->h;
+ particle->pos.y = rand() % SCREEN_HEIGHT;
int snowsize = rand() % 3;
particle->texture = snowimages[snowsize];
do {
for(i = particles.begin(); i != particles.end(); ++i) {
SnowParticle* particle = (SnowParticle*) *i;
particle->pos.y += particle->speed * elapsed_time;
- if(particle->pos.y > screen->h) {
+ if(particle->pos.y > SCREEN_HEIGHT) {
particle->pos.y = fmodf(particle->pos.y , virtual_height);
particle->pos.x = rand() % int(virtual_width);
}
rainimages[0] = new Surface(datadir+"/images/shared/rain0.png", true);
rainimages[1] = new Surface(datadir+"/images/shared/rain1.png", true);
- virtual_width = screen->w * 2;
+ virtual_width = SCREEN_WIDTH * 2;
// create some random raindrops
size_t raindropcount = size_t(virtual_width/8.0);
for(size_t i=0; i<raindropcount; ++i) {
RainParticle* particle = new RainParticle;
particle->pos.x = rand() % int(virtual_width);
- particle->pos.y = rand() % screen->h;
+ particle->pos.y = rand() % SCREEN_HEIGHT;
int rainsize = rand() % 2;
particle->texture = rainimages[rainsize];
do {
RainParticle* particle = (RainParticle*) *i;
particle->pos.y += particle->speed * elapsed_time;
particle->pos.x -= particle->speed * elapsed_time;
- if(particle->pos.y > screen->h) {
+ if(particle->pos.y > SCREEN_HEIGHT) {
particle->pos.y = fmodf(particle->pos.y , virtual_height);
particle->pos.x = rand() % int(virtual_width);
}
bbox.set_pos(Vector(camera->get_translation().x, get_pos().y));
adjust = true;
}
- if(get_pos().x >= camera->get_translation().x + screen->w - bbox.get_width())
+ if(get_pos().x >= camera->get_translation().x + SCREEN_WIDTH - bbox.get_width())
{
bbox.set_pos(Vector(
- camera->get_translation().x + screen->w - bbox.get_width(),
+ camera->get_translation().x + SCREEN_WIDTH - bbox.get_width(),
get_pos().y));
adjust = true;
}
if(start_x < 0) start_x = 0;
float start_y = roundf(context.get_translation().y);
if(start_y < 0) start_y = 0;
- float end_x = std::min(start_x + screen->w, float(width * 32));
- float end_y = std::min(start_y + screen->h, float(height * 32));
+ float end_x = std::min(start_x + SCREEN_WIDTH, float(width * 32));
+ float end_y = std::min(start_y + SCREEN_HEIGHT, float(height * 32));
start_x -= int(start_x) % 32;
start_y -= int(start_y) % 32;
int tsx = int(start_x / 32); // tilestartindex x
if(stats[SCORE_STAT][SPLAYER] == -1) // not initialized yet
return;
- context.draw_text(gold_text, title, Vector(screen->w/2, 410), CENTER_ALLIGN, LAYER_GUI);
+ context.draw_text(gold_text, title, Vector(SCREEN_WIDTH/2, 410), CENTER_ALLIGN, LAYER_GUI);
char str[128];
sprintf(str, _( "Max score: %d"), stats[SCORE_STAT][SPLAYER]);
- context.draw_text(white_text, str, Vector(screen->w/2, 450), CENTER_ALLIGN, LAYER_GUI);
+ context.draw_text(white_text, str, Vector(SCREEN_WIDTH/2, 450), CENTER_ALLIGN, LAYER_GUI);
for(int i = 1; i < NUM_STATS; i++)
{
stats[TIME_NEEDED_STAT][STOTAL]);
- context.draw_text(white_small_text, str, Vector(screen->w/2, 462 + i*18), CENTER_ALLIGN, LAYER_GUI);
+ context.draw_text(white_small_text, str, Vector(SCREEN_WIDTH/2, 462 + i*18), CENTER_ALLIGN, LAYER_GUI);
}
}
Setup::parseargs(argc, argv);
Setup::audio();
- Setup::video(800, 600);
+ Setup::video(screen_width, screen_height);
Setup::joystick();
Setup::general();
st_menu();
if(center) {
context.draw_text(font,
line.substr(1, line.size()-1),
- Vector(screen->w/2, screen->h + y - scroll),
+ Vector(SCREEN_WIDTH/2, SCREEN_HEIGHT + y - scroll),
CENTER_ALLIGN, LAYER_FOREGROUND1);
} else {
context.draw_text(font,
line.substr(1, line.size()-1),
- Vector(left_border, screen->h + y - scroll),
+ Vector(left_border, SCREEN_HEIGHT + y - scroll),
LEFT_ALLIGN, LAYER_FOREGROUND1);
}
context.do_drawing();
- if(screen->h+y-scroll < 0 && 20+screen->h+y-scroll < 0)
+ if(SCREEN_HEIGHT+y-scroll < 0 && 20+SCREEN_HEIGHT+y-scroll < 0)
done = 1;
Uint32 ticks = SDL_GetTicks();
if(center) {
context.draw_text(font,
line.substr(1, line.size()-1),
- Vector(screen->w/2, y),
+ Vector(SCREEN_WIDTH/2, y),
CENTER_ALLIGN, LAYER_GUI);
} else {
context.draw_text(font,
fadeout(256);
DrawingContext context;
context.draw_text(white_text, "Loading...",
- Vector(screen->w/2, screen->h/2), CENTER_ALLIGN, LAYER_FOREGROUND1);
+ Vector(SCREEN_WIDTH/2, SCREEN_HEIGHT/2), CENTER_ALLIGN, LAYER_FOREGROUND1);
context.do_drawing();
// TODO: slots should be available for contrib maps
if (Menu::current() == main_menu)
- context.draw_surface(logo, Vector(screen->w/2 - logo->w/2, 30),
+ context.draw_surface(logo, Vector(SCREEN_WIDTH/2 - logo->w/2, 30),
LAYER_FOREGROUND1+1);
context.draw_text(white_small_text, " SuperTux " PACKAGE_VERSION "\n",
- Vector(0, screen->h - 50), LEFT_ALLIGN, LAYER_FOREGROUND1);
+ Vector(0, SCREEN_HEIGHT - 50), LEFT_ALLIGN, LAYER_FOREGROUND1);
context.draw_text(white_small_text,
_(
"Copyright (c) 2003 SuperTux Devel Team\n"
"This game comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to\n"
"redistribute it under certain conditions; see the file COPYING for details.\n"
),
- Vector(0, screen->h - 50 + white_small_text->get_height() + 5),
+ Vector(0, SCREEN_HEIGHT - 50 + white_small_text->get_height() + 5),
LEFT_ALLIGN, LAYER_FOREGROUND1);
/* Don't draw menu, if quit is true */
LAYER_BACKGROUND0);
context.draw_text(blue_text, _("GAMEOVER"),
- Vector(screen->w/2, 200), CENTER_ALLIGN, LAYER_FOREGROUND1);
+ Vector(SCREEN_WIDTH/2, 200), CENTER_ALLIGN, LAYER_FOREGROUND1);
sprintf(str, _("COINS: %d"), player_status.distros);
context.draw_text(gold_text, str,
- Vector(screen->w/2, screen->w - 32), CENTER_ALLIGN,
+ Vector(SCREEN_WIDTH/2, SCREEN_WIDTH - 32), CENTER_ALLIGN,
LAYER_FOREGROUND1);
total_stats.draw_message_info(context, _("Total Statistics"));
context.draw_text(gold_text, str, Vector(96, 0), LEFT_ALLIGN, LAYER_FOREGROUND1);
sprintf(str, "%d", player_status.distros);
- context.draw_text(white_text, _("COINS"), Vector(screen->w/2 - 16*5, 0),
+ context.draw_text(white_text, _("COINS"), Vector(SCREEN_WIDTH/2 - 16*5, 0),
LEFT_ALLIGN, LAYER_FOREGROUND1);
- context.draw_text(gold_text, str, Vector(screen->w/2 + (16*5)/2, 0),
+ context.draw_text(gold_text, str, Vector(SCREEN_WIDTH/2 + (16*5)/2, 0),
LEFT_ALLIGN, LAYER_FOREGROUND1);
if (player_status.lives >= 5)
{
sprintf(str, "%dx", player_status.lives);
context.draw_text(gold_text, str,
- Vector(screen->w - gold_text->get_text_width(str) - tux_life->w, 0),
+ Vector(SCREEN_WIDTH - gold_text->get_text_width(str) - tux_life->w, 0),
LEFT_ALLIGN, LAYER_FOREGROUND1);
- context.draw_surface(tux_life, Vector(screen->w -
+ context.draw_surface(tux_life, Vector(SCREEN_WIDTH -
gold_text->get_text_width("9"), 0), LEFT_ALLIGN, LAYER_FOREGROUND1);
}
else
{
for(int i= 0; i < player_status.lives; ++i)
context.draw_surface(tux_life,
- Vector(screen->w - tux_life->w*4 + (tux_life->w*i), 0),
+ Vector(SCREEN_WIDTH - tux_life->w*4 + (tux_life->w*i), 0),
LAYER_FOREGROUND1);
}
context.draw_text(white_text, _("LIVES"),
- Vector(screen->w - white_text->get_text_width(_("LIVES")) - white_text->get_text_width(" 99"), 0),
+ Vector(SCREEN_WIDTH - white_text->get_text_width(_("LIVES")) - white_text->get_text_width(" 99"), 0),
LEFT_ALLIGN, LAYER_FOREGROUND1);
if (!tux->is_moving())
get_level_title(*i);
context.draw_text(white_text, i->title,
- Vector(screen->w/2,
- screen->h - white_text->get_height() - 30),
+ Vector(SCREEN_WIDTH/2,
+ SCREEN_HEIGHT - white_text->get_height() - 30),
CENTER_ALLIGN, LAYER_FOREGROUND1);
i->statistics.draw_worldmap_info(context);
/* Display an in-map message in the map, if any as been selected */
if(!i->map_message.empty() && !i->passive_message)
context.draw_text(gold_text, i->map_message,
- Vector(screen->w/2,
- screen->h - white_text->get_height() - 60),
+ Vector(SCREEN_WIDTH/2,
+ SCREEN_HEIGHT - white_text->get_height() - 60),
CENTER_ALLIGN, LAYER_FOREGROUND1);
break;
}
/* Display a passive message in the map, if needed */
if(passive_message_timer.check())
context.draw_text(gold_text, passive_message,
- Vector(screen->w/2, screen->h - white_text->get_height() - 60),
+ Vector(SCREEN_WIDTH/2, SCREEN_HEIGHT - white_text->get_height() - 60),
CENTER_ALLIGN, LAYER_FOREGROUND1);
context.pop_transform();
Vector tux_pos = tux->get_pos();
- offset.x = -tux_pos.x + screen->w/2;
- offset.y = -tux_pos.y + screen->h/2;
+ offset.x = -tux_pos.x + SCREEN_WIDTH/2;
+ offset.y = -tux_pos.y + SCREEN_HEIGHT/2;
if (offset.x > 0) offset.x = 0;
if (offset.y > 0) offset.y = 0;
- if (offset.x < screen->w - width*32) offset.x = screen->w - width*32;
- if (offset.y < screen->h - height*32) offset.y = screen->h - height*32;
+ if (offset.x < SCREEN_WIDTH - width*32) offset.x = SCREEN_WIDTH - width*32;
+ if (offset.y < SCREEN_HEIGHT - height*32) offset.y = SCREEN_HEIGHT - height*32;
context.push_transform();
context.set_translation(-offset);