View previous topic :: View next topic |
Author |
Message |
Baker

Joined: 14 Mar 2006 Posts: 1538
|
Posted: Tue Jan 12, 2010 12:45 pm Post subject: |
|
|
qbism wrote: | Sorry two separate issues-
1. code snip for mouse reattach? |
Found in http://www.quake-1.com/docs/flashquake/FlashProQuake400_v2_src.rar in Main.as
I rewired the mouse a bit and increased sensitivity to make the mouse usage far more playable.
I *do not* believe I included Rennie's "sound delay" fix in that source. The next time I update this (*) I'll add that if it isn't in there and I don't think it is (it's in Rennie's SVN ... see page 1 of this thread) if you want it badly. I'm thinking only 3 files were affected, snd_<something>.c and one of the .as files (Main.as ?) plus maybe snd_null.c [the ProQuake version equivalent is snd_flash.c; snd_null.c is for no sound = bad name = I renamed it).
(*) = will not likely be soon, I'd need to port some software features from Makaqu/FTEQW to software ProQuake to get excited enough to do this due to the other stuff I have going on.
Code: | package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.ui.Mouse;
import flash.utils.ByteArray;
import cmodule.quake.CLibInit;
import flash.utils.getTimer;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.net.SharedObject;
import flash.display.StageScaleMode;
import flash.events.SampleDataEvent;
import flash.media.SoundChannel;
import flash.media.Sound;
/**
* ...
* @author Michael Rennie
*/
public class Main extends Sprite
{
private var _loader:CLibInit;
private var _swc:Object;
private var _swcRam:ByteArray;
private var _bitmapData:BitmapData;//This is null until after we have called the first _swc.swcFrame()
private var _bitmap:Bitmap;
private var _rect:Rectangle;
private var _sound:Sound;
private var _soundChannel:SoundChannel;
private var _lastSampleDataPosition:int;//Reset to 0 everytime a restart the sound.
private var _oldmouseX:int, _oldmouseY:int;
private var _buttonDown:Boolean = false;
private var _buttonDown_lost:Boolean = false; // If mouselook and mouse moved off screen, we want to ignore movement until it re-centers
[Embed(source="../embed/PAK0.PAK", mimeType="application/octet-stream")]
private var EmbeddedPak:Class;
// [Embed(source="../embed/config.cfg", mimeType="application/octet-stream")]
// private var EmbeddedDefaultConfig:Class;
private var loader2:URLLoader = new URLLoader();
//
//
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
_sound = new Sound();
_sound.addEventListener( SampleDataEvent.SAMPLE_DATA, sampleDataHandler );
//init swc
_loader = new CLibInit;
_swc = _loader.init();
//If we havent already got a config.cfg saved in the SharedObjects, then we load the embedded one.
//This will override some default controls from default.cfg inside the pak file, which 99% of users will change.
//(WASD keys, as well as Always Run).
// fileSupplyDefaultEmbedded("./id1/config.cfg", EmbeddedDefaultConfig);
URLRequestExample ();
var pakFile:ByteArray = new EmbeddedPak;
_loader.supplyFile("./id1/pak0.pak", pakFile);
_swcRam = _swc.swcInit(this);
stage.addEventListener(Event.ENTER_FRAME, onFrame);
addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
// Set button to up
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
}
private function URLRequestExample() {
var loader:URLLoader = new URLLoader();
configureListeners(loader);
var request:URLRequest = new URLRequest("XMLFile.xml");
try {
loader.load(request);
fileSupplyDefaultEmbedded("./id1/config.cfg", EmbeddedDefaultConfig);
} catch (error:Error) {
trace("Unable to load requested document.");
}
}
private function onFrame(e:Event):void
{
if ( _buttonDown == false && _buttonDown_lost == true)
{
// Involuntary loss, check for inner 20% reattachment
var recapturex1:int = (stage.stageWidth / 16) * 7;
var recapturex2:int = (stage.stageWidth / 16) * 9;
var recapturey1:int = (stage.stageHeight / 16) * 7;
var recapturey2:int = (stage.stageHeight / 16) * 9;
if ( (recapturex1 < mouseX && mouseX < recapturex2 ) && (recapturey1 < mouseY && mouseY < recapturey2) )
{
// Kazaam! Recapture it!
_oldmouseX = mouseX;
_oldmouseY = mouseY;
_buttonDown = true;
_buttonDown_lost = false;
Mouse.hide();
trace ("Recapture at" + mouseX + " , " + mouseY);
}
}
//Check for mouse movement. It is much more accurate to do this every frame than in a MOUSE_MOVE event.
if(_buttonDown)
{
var deltaX:int = mouseX - _oldmouseX;
var deltaY:int = mouseY - _oldmouseY;
//trace (mouseX, mouseY);
//trace (stage.stageWidth, stage.stageHeight);
const MOUSE_MULTIPLIER:Number = 8;
_swc.swcDeltaMouse(deltaX * MOUSE_MULTIPLIER, deltaY * MOUSE_MULTIPLIER);
}
_oldmouseX = mouseX;
_oldmouseY = mouseY;
//Run the game frame, and get the pointer to its frame buffer
var newTime:Number = getTimer() / 1000;
var ptr:uint = _swc.swcFrame(newTime);
if (!_bitmapData)
{
//Wait for the first frame before adding the bitmap.
var width:uint = 640;
var height:uint = 480;
_bitmapData = new BitmapData(width, height, false);
_rect = new Rectangle(0, 0, width, height);
_bitmap = new Bitmap(_bitmapData);
addChild(_bitmap);
}
_swcRam.position = ptr;
_bitmapData.setPixels(_rect, _swcRam);
if (!_soundChannel)
{
_lastSampleDataPosition = 0;
_soundChannel = _sound.play();
_soundChannel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
}
}
private function soundCompleteHandler(e:Event):void
{
//The sound stopped playing because it ran out of samples, so make it restart next frame.
_soundChannel.removeEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
_soundChannel = null;
}
private function sampleDataHandler(event:SampleDataEvent):void
{
//The sound channel is requesting more samples. If it ever runs out then a sound complete message will occur.
//Ask the game to paint its channels to our sample ByteArray.
//Also need to supply a deltaT to update the game's internal sound time.
var soundDeltaT:int = event.position - _lastSampleDataPosition;
_swc.swcWriteSoundData(event.data, soundDeltaT);
_lastSampleDataPosition = event.position;
}
private function onKeyDown( e:KeyboardEvent ):void
{
//trace("onKeyDown: ", e.keyCode, ", ", e.charCode, ", ", String.fromCharCode(e.charCode));
_swc.swcKey(e.keyCode, e.charCode, 1);
}
private function onKeyUp( e:KeyboardEvent ):void
{
_swc.swcKey(e.keyCode, e.charCode, 0);
}
private function onMouseDown(e:MouseEvent):void
{
if (_buttonDown)
{
_buttonDown = false;
_buttonDown_lost = false;
Mouse.show();
} else {
_oldmouseX = mouseX;
_oldmouseY = mouseY;
_buttonDown = true;
_buttonDown_lost = false;
Mouse.hide();
}
}
private function onMouseUp(e:MouseEvent):void
{
//_buttonDown = false;
//Mouse.show();
}
private function mouseOutHandler(e:MouseEvent):void
{
// We could sleep here maybe ... bad idea
if (_buttonDown)
{
_buttonDown_lost = true; // Involuntary
_buttonDown = false;
Mouse.show();
trace ("Lost mouse!");
}
}
//We keep a record of the ByteArray for each file, because CLibInit.supplyFile
//only allows a file to be supplied with a ByteArray ONCE only.
private var _fileByteArrays:Array = new Array;
public function fileSupplyDefaultEmbedded(filename:String, defaultEmbed:Class):void
{
if (!fileReadSharedObject(filename))//Check if its in the SharedObjects first
{
//Havent yet got the file saved in the SharedObjects, so we load the embedded data as its default value.
var file:ByteArray = new defaultEmbed;
_fileByteArrays[filename] = file; //So that we can still overwrite it
_loader.supplyFile(filename, file);//So that it can be read later on
}
}
public function fileReadSharedObject(filename:String):Boolean
{
var sharedObject:SharedObject = SharedObject.getLocal(filename);
if (!sharedObject)
return false; //Shared objects not enabled
if (!sharedObject.data.byteArray)
return false; //Havent yet saved a shared object for this file
if (!_fileByteArrays[filename])
{
//This is the first time we are accessing this file, so record and supply the ByteArray for it
//from the SharedObject
var byteArray:ByteArray = sharedObject.data.byteArray;
_fileByteArrays[filename] = byteArray;
_loader.supplyFile(filename, byteArray);
}
return true;//We did find its SharedObject, so return true
}
public function fileWriteSharedObject(filename:String):ByteArray
{
var sharedObject:SharedObject = SharedObject.getLocal(filename);
if (!sharedObject)
return undefined; //Shared objects not enabled
var byteArray:ByteArray;
if (!_fileByteArrays[filename])
{
//Havent yet created a ByteArray for this file, so create a blank one.
byteArray = new ByteArray;
_fileByteArrays[filename] = byteArray;
//Supply the ByteArray as a file, so that it can also be read later on, if needed.
_loader.supplyFile(filename, byteArray);
}
else
{
byteArray = _fileByteArrays[filename];
//We are opening the file for writing, so reset its length to 0.
//Needed because this is NOT done by funopen(byteArray, ...)
byteArray.length = 0;
}
//Return the ByteArray, allowing it to be opened as a FILE* for writing using funopen(byteArray, ...)
return byteArray;
}
//SharedObjects are used to save quake config files
public function fileUpdateSharedObject(filename:String):void
{
var sharedObject:SharedObject = SharedObject.getLocal(filename);
if (!sharedObject)
return; //Shared objects not enabled
if (!_fileByteArrays[filename])
{
//This can happen if fileUpdateSharedObject is called before fileWriteSharedObject or fileReadSharedObject
trace("Error: fileUpdateSharedObject() called on a file without a ByteArray");
}
sharedObject.data.byteArray = _fileByteArrays[filename];
sharedObject.flush();
}
// Newbs start here
private function configureListeners(dispatcher:IEventDispatcher):void {
dispatcher.addEventListener(Event.COMPLETE, completeHandler);
dispatcher.addEventListener(Event.OPEN, openHandler);
dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
}
private function completeHandler(event:Event):void {
var loader:URLLoader = URLLoader(event.target);
trace("completeHandler: " + loader.data);
}
private function openHandler(event:Event):void {
trace("openHandler: " + event);
}
private function progressHandler(event:ProgressEvent):void {
trace("progressHandler loaded:" + event.bytesLoaded + " total: " + event.bytesTotal);
}
private function securityErrorHandler(event:SecurityErrorEvent):void {
trace("securityErrorHandler: " + event);
}
private function httpStatusHandler(event:HTTPStatusEvent):void {
trace("httpStatusHandler: " + event);
}
private function ioErrorHandler(event:IOErrorEvent):void {
trace("ioErrorHandler: " + event);
}
}
} |
By the way, switching Flash to fullscreen mode is quite doable but for security reasons you lose all ability to use the keyboard. As a result, switching to full screen mode is only viable for playing demos where just watching is all you want (ProQuake has demo rewind and fast forward via PGUP/PGDN). |
|
Back to top |
|
 |
JasonX
Joined: 21 Apr 2009 Posts: 89
|
Posted: Tue Jan 12, 2010 9:27 pm Post subject: |
|
|
When i try to run make -f makeswc, cygwin says:
make: command not found
I just downloaded the pack and ran the instructions. What could possibly be wrong? |
|
Back to top |
|
 |
Baker

Joined: 14 Mar 2006 Posts: 1538
|
Posted: Tue Jan 12, 2010 9:42 pm Post subject: |
|
|
JasonX wrote: | When i try to run make -f makeswc, cygwin says:
make: command not found
I just downloaded the pack and ran the instructions. What could possibly be wrong? |
My quick guess:
qbism wrote: | Baker, the download unzipped. Still had to install Cygwin from scratch, couldn't find paths. Followed your config instructions. All the compile steps worked after that (Proquake). |
qbism said he needed to install Cygwin from scratch even with the huge zip download because it couldn't find the paths.
Try installing cygwin from scratch to c:\cygwin and then unzipping the huge 685 MB archive to c:\cygwin folder. (The install zip IS NOT drive/path flexible at all --- not c:\program files\cygwin or d:\cygwin or e:\cygwin).
Then try to compile.
If that fails, you might have to fallback to the 22 step setup way earlier in this thread.
Eventually I'm going to take another look at the huge archive download and install from scratch on another machine to see if I can ensure that by itself it can compile as is after download/unarchive.
But I have a large to-do list and that won't be immediate ... _________________ Tomorrow Never Dies. I feel this Tomorrow knocking on the door ... |
|
Back to top |
|
 |
JasonX
Joined: 21 Apr 2009 Posts: 89
|
Posted: Tue Jan 12, 2010 9:45 pm Post subject: |
|
|
I made a clean install of cygwin, same problem. I then unzipped the prepared archive, and tried again, same problems.  |
|
Back to top |
|
 |
Baker

Joined: 14 Mar 2006 Posts: 1538
|
Posted: Tue Jan 12, 2010 9:50 pm Post subject: |
|
|
JasonX wrote: | I made a clean install of cygwin, same problem. I then unzipped the prepared archive, and tried again, same problems.  |
Sorry to hear that. Well, for now it would appear that only the "hard road" option is available: http://forums.inside3d.com/viewtopic.php?p=19420#19420
I want this to be download and go for the compile so more people can easily mod the FlashQuake port, so I'll revisit this when I can.
Time frame unknown, at the moment. _________________ Tomorrow Never Dies. I feel this Tomorrow knocking on the door ... |
|
Back to top |
|
 |
rdza
Joined: 31 Dec 2009 Posts: 2
|
Posted: Wed Jan 13, 2010 1:16 am Post subject: |
|
|
Hey Baker, good stuff.
My fingers are crossed for a working fteqw in flash, that would give us Q1, 2, Hexen2, and quake-life, how awesome would that be.
And maybe if we're lucky Rennie will hook up a flash network socket for multiplayer  |
|
Back to top |
|
 |
qbism

Joined: 04 Nov 2004 Posts: 82
|
Posted: Wed Jan 13, 2010 1:30 am Post subject: |
|
|
To the best of my recollection:
1. install cygwin the normal way, with the autoinstaller.
2. unpack Baker's zip to a temp folder.
3. copy over ONLY the edited config files and jre6 directory into the fresh cygwin install.
4. move alchemy and flex-blah-blah dirs directly under c: drive. (C:/alchemy)
5. Add the c:\cygwin\jre6\bin folder (Java binaries) to the Windows system path.
6. I didn't even try compiling the "vanilla" flashquake. I replaced it with the proquake version. Put it in the same place, under c:/alchemy/samples.
7. The autoinstaller made a desktop link. Use that to start cygwin and follow the build instructions from there. _________________ http://qbism.com
Last edited by qbism on Thu Jan 14, 2010 12:35 pm; edited 1 time in total |
|
Back to top |
|
 |
JasonX
Joined: 21 Apr 2009 Posts: 89
|
Posted: Thu Jan 14, 2010 3:17 am Post subject: |
|
|
Very strange:
Code: | cd Release; gcc -Wall -Werror-implicit-function-declaration -DFLASH -DNO_ASM -O
3 -c ../../WinQuake/nonintel.c -o nonintel.o
In file included from ../../WinQuake/nonintel.c:24:
../../WinQuake/quakedef.h:45:17: AS3.h: No such file or directory
In file included from ../../WinQuake/quakedef.h:215,
from ../../WinQuake/nonintel.c:24:
../../WinQuake/common.h:224:7: warning: no newline at end of file
In file included from ../../WinQuake/quakedef.h:218,
from ../../WinQuake/nonintel.c:24:
../../WinQuake/sys.h:72:22: warning: no newline at end of file
In file included from ../../WinQuake/quakedef.h:234,
from ../../WinQuake/nonintel.c:24:
../../WinQuake/wad.h:80:7: warning: no newline at end of file
In file included from ../../WinQuake/quakedef.h:239,
from ../../WinQuake/nonintel.c:24:
../../WinQuake/security.h:55:7: warning: no newline at end of file
In file included from ../../WinQuake/quakedef.h:259,
from ../../WinQuake/nonintel.c:24:
../../WinQuake/console.h:44:30: warning: no newline at end of file
In file included from ../../WinQuake/quakedef.h:263,
from ../../WinQuake/nonintel.c:24:
../../WinQuake/cdaudio.h:32:7: warning: no newline at end of file
In file included from ../../WinQuake/quakedef.h:268,
from ../../WinQuake/nonintel.c:24:
../../WinQuake/r_local.h:313:82: warning: no newline at end of file
make: *** [Release/nonintel.o] Error 1 |
|
|
Back to top |
|
 |
qbism

Joined: 04 Nov 2004 Posts: 82
|
Posted: Thu Jan 14, 2010 3:31 am Post subject: |
|
|
alc-on _________________ http://qbism.com |
|
Back to top |
|
 |
JasonX
Joined: 21 Apr 2009 Posts: 89
|
Posted: Thu Jan 14, 2010 12:03 pm Post subject: |
|
|
Code: | bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
bash: $'\r': command not found
: No such file or directorylchemy-setup
': not a valid identifier
bash: $'\r': command not found
': not a valid identifier
bash: $'\r': command not found
': not a valid identifier
bash: $'\r': command not found
': not a valid identifier
bash: $'\r': command not found
bash: $'\r': command not found
bash: /etc/profile: line 84: syntax error near unexpected token `$'in\r''
bash: /etc/profile: line 84: `case "`echo "_$0" | /usr/bin/tr '[:upper:]' '[:low
'r:]' | /usr/bin/sed -e 's/^_//'`" in
bash-3.2$ alc-on
bash: alc-on: command not found
bash-3.2$ |
My profile:
Code: | source /cygdrive/c/alchemy/alchemy-setup
PATH=/usr/local/bin:/usr/bin:/bin:/jre6/bin:/cygdrive/c/flex/bin:$ALCHEMY_HOME/achacks:$PATH
export PATH |
|
|
Back to top |
|
 |
qbism

Joined: 04 Nov 2004 Posts: 82
|
Posted: Thu Jan 14, 2010 12:35 pm Post subject: |
|
|
Looking in Baker's long-form instructions:
Add the c:\cygwin\jre6\bin folder (Java binaries) to the Windows system path.
Going to add this to my list above! _________________ http://qbism.com |
|
Back to top |
|
 |
JasonX
Joined: 21 Apr 2009 Posts: 89
|
Posted: Thu Jan 14, 2010 1:10 pm Post subject: |
|
|
I already added both JRE and Flex paths to the PATH environment variable.  |
|
Back to top |
|
 |
JasonX
Joined: 21 Apr 2009 Posts: 89
|
Posted: Fri Jan 15, 2010 1:21 pm Post subject: |
|
|
Re-downloaded and re-installed everything. Same problems. I then re-downloaded the big package from Baker, tried it on top of my fresh installation of everything, and the same error occurred.
Maybe i'm missing something small? |
|
Back to top |
|
 |
Baker

Joined: 14 Mar 2006 Posts: 1538
|
Posted: Fri Jan 15, 2010 2:19 pm Post subject: |
|
|
JasonX wrote: | Re-downloaded and re-installed everything. Same problems. I then re-downloaded the big package from Baker, tried it on top of my fresh installation of everything, and the same error occurred.
Maybe i'm missing something small? |
I've set this up from scratch on 3 machines; the instructions work.
And by documenting it thoroughly, I have made it FAR easier than the 2 full days it took for me to successfully compile the first time.
Stubbornness and attention to detail are prerequisites for engine modification.
Try again, be very careful and patient and follow the instructions to a T. Even the slightest mistake or deviation from the setup instructions will cause the setup to fail.
Add: When you setup Cygwin, there is some sort of carriage return versus newline option. I hope you selected whatever the default was. _________________ Tomorrow Never Dies. I feel this Tomorrow knocking on the door ... |
|
Back to top |
|
 |
JasonX
Joined: 21 Apr 2009 Posts: 89
|
Posted: Mon Jan 18, 2010 7:01 pm Post subject: |
|
|
After a few days banging my head against a wall, i'm getting this:
Code: |
$ make -f makeswc
cd Release; gcc -Wall -Werror-implicit-function-declaration -DFLASH -DNO_ASM -O
3 -c ../../WinQuake/nonintel.c -o nonintel.o
In file included from ../../WinQuake/nonintel.c:24:
../../WinQuake/quakedef.h:45:17: AS3.h: No such file or directory
In file included from ../../WinQuake/quakedef.h:215,
from ../../WinQuake/nonintel.c:24:
../../WinQuake/common.h:224:7: warning: no newline at end of file
In file included from ../../WinQuake/quakedef.h:218,
from ../../WinQuake/nonintel.c:24:
../../WinQuake/sys.h:72:22: warning: no newline at end of file
In file included from ../../WinQuake/quakedef.h:234,
from ../../WinQuake/nonintel.c:24:
../../WinQuake/wad.h:80:7: warning: no newline at end of file
In file included from ../../WinQuake/quakedef.h:239,
from ../../WinQuake/nonintel.c:24:
../../WinQuake/security.h:55:7: warning: no newline at end of file
In file included from ../../WinQuake/quakedef.h:259,
from ../../WinQuake/nonintel.c:24:
../../WinQuake/console.h:44:30: warning: no newline at end of file
In file included from ../../WinQuake/quakedef.h:263,
from ../../WinQuake/nonintel.c:24:
../../WinQuake/cdaudio.h:32:7: warning: no newline at end of file
In file included from ../../WinQuake/quakedef.h:268,
from ../../WinQuake/nonintel.c:24:
../../WinQuake/r_local.h:313:82: warning: no newline at end of file
make: *** [Release/nonintel.o] Error 1
|
|
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2004 phpBB Group
|