konForce

Members
  • Content count

    355
  • Joined

  • Last visited

Community Reputation

592 Good

About konForce

  • Rank
    Member
  1. Allegro beginner help?

    Your "if" block isn't doing anything because it only gets checked once. Hitting enter is taking you past the readkey() line. Check to make sure "instructions" is not a NULL pointer. The crash is probably happening on "destroy_bitmap(instructions);".
  2. Check your JS settings. FF by default disables the ability to "Raise or lower windows."
  3. [web] Custom HTML Tags

    Just do: <style type="text/css"> div.foo { } span.bar { } </style> <div class="foo">a</div> <span class="bar">b</span>
  4. Allegro wont take certain sizes

    In Allegro 4, the screen width must be divisible by four. In the odd chance that limitation is problematic, then you can blit your back buffer at (dx,0) or create a centered sub-bitmap of the desired width.
  5. [web] PHP file_exists problem

    file_exists() works with the local file system, so you'll need to pass the local path, such as /var/www/html/images/foo.jpg.
  6. [web] php redirection

    You should probably use output buffering. It's generally a useful thing, and it prevents errors like this.
  7. Allegro cpu problem

    I believe some of those require that Allegro be compiled with the assembly code enabled.
  8. Allegro without DirectX

    DX also provides sound output. Link against winmm.lib.
  9. Allegro without DirectX

    Allegro uses DirectX for Windows. If you link with alleg_s.lib, you need to link against the DX libraries. It's all covered in the build instructions.
  10. The correct sequence is: #include <allegro.h> #include <winalleg.h> // other windows headers, but never windows.h See the section in the manual under "Windows Specifics."
  11. [web] OO in PHP

    At one point I was a straight up procedural programmer in PHP. My code looked something like: require_once('common.inc.php'); $news = $db->getAll("SELECT * FROM news_item ORDER BY dt DESC LIMIT 10"); include('header.inc.php'); ?> <ul> <?foreach ($news as $n):?> <li> <h1><?=$n[title']?></h1> <p><?=$n['description']?></h1> </li> <?endforeach;?> </ul> include('footer.inc.php'); There would be a news/add.php page, a news/edit.php page, etc. All was well because, after all, it was just a single, small site and easy to maintain. But that grew into a few small sites and then a large site, and then more and more. I would copy/paste as best I could, but after years of that, it becomes too hard to handle and the differences between sites make it hard to share code. Now I work with a complete OOP framework I wrote from the bottom up that focuses on reusing code modules across every site. Every site I create and host operates on the same exact codebase. The above code might look more like: class Module_News { public function requestHandler(HTTPRequest $req) { if ($req->path = '/news') { $tpl->news = News::fetchRecent(); return $tpl->render('News/index'); } } } Then that would render a template page: <ul> <li tpl:loop="n; news"> <h1>{n.title}</h1> <p>{n.description}</p> </li> </ul> There are lots of different ways to handle this, and it's not necessarily an OOP vs non-OOP idea. That is, you could do this without any OOP if you really didn't want to use it. But the point is that there is a clean separation between everything. Sites can share the code modules among themselves easily and, if necessary, extend the classes to provide minor modifications. Then the template pages can easily be changed per website to give whatever look they want; as an added bonus, template pages are able to include any read-only data that is defined for the site, so pages can really be quite unique. In other words, it's not about using OOP to "increase the performance," it's about having some sort of methodology that allows you to easily maintain and reuse your code forever. You can always buy a faster computer, but you'll never be able to get back the time you waste redoing the same sort of thing over and over again due to a lack of planning.
  12. [web] Flash problems on Linux

    If other hosted flash works, then I would check for the obvious differences between platforms like case sensitive paths, etc. Without more information, we are just left to guess at the possibilities.
  13. [web] Apache Authentication

    It is cached for the duration of your session.
  14. [Allegro] timers & animation

    Variables that are called in timers must be locked if you run your code on DOS or Mac OS 9. You can safely ignore it. The reason why it was important on those operating systems is because timers were implemented as interrupts. It's no longer relevant, although it won't hurt to add those macros. Under all other operating systems, Allegro timers are just threads. From the manual: Quote: Under other platforms, they are usually implemented using threads, which run parallel to the main thread. Therefore timer callbacks on such platforms will not block the main thread when called, so you may need to use appropriate synchronisation devices (eg. mutexes, semaphores, etc.) when accessing data that is shared by a callback and the main thread. (Currently Allegro does not provide such devices.) Generally speaking the only usefulness of an Allegro timer is to increment a tick variable and monitor that in your main section. The tick variable must be volatile or else the compiler may optimize it away when you use it elsewhere because it won't know that the value has the potential to change. I suggest that you look at the examples that come with the Allegro source. There are some basic examples. The easiest way to do this is to just have a single tick variable that is incremented 60 (or 120, etc) times a second. Then you do this: while (playing) { while (ticker) // ticker will be incremented 60 times per second by your timer { do_logic(); draw_gfx = 1; ticker--; } if (graw_gfx) { do_gfx(); draw_gfx = 0; } else rest(1); // try not to burn up 99% of CPU } Inside your do_logic() routine, you might do something like this: if (my_sprite.ticks++ > my_sprite.ticksPerFrame) { my_sprite.frame++; my_sprite.ticks = 0; } Then when you draw the sprite in the do_gfx() routine, you look at which frame it is currently on and draw accordingly.
  15. [Allegro] anti-aliased ellipses?

    Allegro does not support anti-aliased primitives. You can try searching for them on Google or allegro.cc, but I'm not aware of any well maintained add-ons that provide that functionality. You may be better off with a vector graphics library.