Operation Watergate

Started by Kman1011, October 18, 2022, 06:29:21 PM

Previous topic - Next topic

Kman1011

Ok. I'll check it out. Thanks for letting me know.
Ahh... Another visitor. Stay awhile....STAY FOREVER!!!...MWA-HA-HA-HA

Kman1011

Ok. Uploaded a new file.

It downloads and extracts files ok however now I seem to have issues when I try to start the game from the main Menu.

This only happens on the version I extract. Does not happen on the original folder I work from. All the files seem to be intact on the extracted version.

Don't understand but maybe its just me. ???
Ahh... Another visitor. Stay awhile....STAY FOREVER!!!...MWA-HA-HA-HA

stevmjon

i remember ages ago needing to copy/paste 3 DLL files from the playbasic install folder to the saved file folder where your .exe launcher is.

also, i downloaded successfully, but when i launched the game it ran for a few seconds then my anti-virus claims it had a threat in it and it got quarantined/removed.
i wasn't given the option of keeping it... see pic.

i will try installing again and see if i can get my anti-virus settings to leave it alone.

It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

kevin


Quotei remember ages ago needing to copy/paste 3 DLL files from the playbasic install folder to the saved file folder where your .exe launcher is.

  Yep..  That's the recommended method these days as exe's need to uppack prior to running,  unfortunately this means that 3rd parties tend assume that's malicious,  we know it's not,  but they don't.       


 

Kman1011

Just a note I have the issue resolved with the program crashing.

It was trying to load components outside the Working folder.

Stevmjon - I was thinking that in the back of my mind as I was uploading the program about the .exe files being traced as a virus. I thought that this site would take care of that somehow.

This is my first time uploading a game to a sharing site so if there is anything that would help or is missing, let me know.
Ahh... Another visitor. Stay awhile....STAY FOREVER!!!...MWA-HA-HA-HA

stevmjon

if i remember correctly, copy these 3 dll files from the folder that has the version of playbasic you are using to make your game (this is important).

PB_VGFX.dll
PB_VM.dll
pbsyslib.dll

paste these in the folder of your game demo that has the source files.
run your game at least once so playbasic knows the dll files are in there.
create the .exe file  (if one is already in there let it be overwritten or delete it first before creating the new .exe file)
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

piamoo

To Kman1011, 

There are four screenshots here: https://kman1011.itch.io/operation-watergate

Wow! Really beautiful! Yeah!!!!!

Perhaps replacing the screenshot on https://kman1011.itch.io/ with one of the above beautiful screenshot is a good idea? The reason:

If people use the search function of Itch to look for games, an attractive screenshot has an advantage in making these people click this screenshot. The current screenshot doesn't look too attractive.
https://itch.io/search?q=operation+watergate

By the way, you have several interesting videos on Youtube. Actually, some people also placed Youtube videos. Example: https://lunar-wire.itch.io/paint-bucket-pals

One more idea. No messageboard here: https://kman1011.itch.io/operation-watergate

If there is no messageboard, how can visitors who like your game write down "Excellent game!", "Well done!", "The game looks interesting!", etc.?




kevin

Kman1011,

     Having a mess with it today, but I just get a black screen when I start the level.   Was confused as to what I'm meant to type to start a new mission,  so just assume that's a save file.   

     I'm picking through the included code and there's a few things right off the bat that would be better for the user experience since it's loading a lot of media up front.  So load the first important font then display the loading screen and call sync.   On first load it's going to take a long time to load as none thee media will be cached by the windows file system,  so giving that user feedback..  is like saying hey i'm not dead.. i'm loading
 

eg.

PlayBASIC Code: [Select]
.  openscreen stuff

.. init variables and arrays if you like

LoadFont "Ariel",5,18,1,1
SetFont 5:Ink $0004CC
CenterText GetScreenWidth()/2,GetScreenHeight()/2,"L O A D I N G . . ."
Sync

.. then start loading the media





     This will make sure the screen looks aliev and it's doing it's job..  At the end of each section you could have a the message change



PlayBASIC Code: [Select]
.  openscreen stuff

.. init variables and arrays if you like

LoadFont "Ariel",5,18,1,1
SetFont 5:Ink $0004CC
CenterText GetScreenWidth()/2,GetScreenHeight()/2,"L O A D I N G . . ."
Sync

.. then start loading the media

cls
CenterText GetScreenWidth()/2,GetScreenHeight()/2,"L O A D I N G . . . SOUNDS"
Sync

.. load the sounds

cls
CenterText GetScreenWidth()/2,GetScreenHeight()/2,"L O A D I N G . . . ANIMATIONS"
Sync

;; load animations

etc





     On a fast machine they'll only see these briefly, but for tothers it gets keep the window alive and the users feeling like it's actually doing something

kevin

#23
  PlayBASIC Code Tweaking - Operation Watergate - (2023-02-11)


  Kman mentioned there's been performance issues on his laptop and was kind enough share the source code for me to pick over.    So in this video I  pick through the code (at very a superficial level mainly) aiming to help it's runtime performance and gives tips about alternative approaches where the idea takes me..  

  How'd much faster did we make it ??  Watch and find out

 



 
hello welcome my name is Kevin Picone and I'm the developer of play basic uh
recently one of our foreign members came in he released a game called operation
Watergate 2. you mentioned there were some performance issues with it and luckily he's included the source code
with the demo so let's load the demo up and we'll have a bit of a sticky note through how it's
running and I think it's probably probably buffer related management that's probably the issue
and we'll see how we go all right so
I've unzipped the package the I've unzipped operation watergate
it does include the code so which is fantastic just drag it across the play basic now he he's using play basic 164p
and I'm using revision four of that now hopefully he knows this up more up-to-date versions the noise using
uh but it does work fine in this version anyway not without saying there are there are
issues now I have run this before and I will change something up up front
I don't want to change into full screen exclusive it's one of the terrain as a window
so we can capture the window so as we're running it um let's have a go that's right
F5 to run it'll do a build and then we're loading
uh I've just been feeling around with this before so a lot of the files will actually be pre-cashed
by the operating system already but it still takes a while to load
it's one of those ones where when I first ran the game I was thinking oh is it
has it crashed is it doing something is you know so it needs something to have
some response back to the user the smallest thing would make someone
comfortable with in what's doing right
[Music]
okay it was just there's this weird pause initially
we haven't started playing yet not quite sure what it's doing the pro
I'm not quite sure the logic behind how it's it's written there we go
uh for those who are old like myself you might remember impossible mission
it's like an isometric version of that it's a great idea actually I'm
can't believe I never thought of it myself but um so clearly we've got some performance
issues with our frame right they'll be ironic that's a good thing we
unless it's running we'll address the performance stuff as we go through
if you focus your attention down here you'll see it's drawing a bunch of lines there
now if you're drawing lines uh to the screen in particular
um directly and not locking the buffer between the line drawers you end up with
a lot of lost time in PVE requests a lock of the surface draws
the line unlocks the surface only allocated to go and draw another line and then have to repeat that
request of lock unlock process unfortunately that's very slow in contemporary systems
or as it used to be you know wow wow not fantastic but it used to be a lot
easier for those things I'm thinking when people was was developed by the way which is back in
the early 2000s contemporary video drivers certainly
support director or that's the problem so we have to sort of adjust ourselves to working with how
they want to work as opposed to how we want to work I escaped to break out
now I kind of know what the problem is going to be so
but that load thing so we follow the follow the logic
through we've got a bunch of setup here it's got some structures setting up
object Bots some sort of global structures here
arise quite a big one there actually I'm not quite sure why didn't all that needs to
be so large a three-dimensional array for objects you know that's um
oh geez so 64 000
you've got eight by eight so it's 64 times uh what was it twenty thousand
times the size of the object structure plus anywhere any sort of bounding of that
that's that's a lot of memory to soak up in that kind of structure
so all of this here is set up I don't know how this works I don't know what this is they're not
documented I don't know what they're doing uh my general advice would be to
have this this initial font load
and even right at the top
right so we would do something like this we'd go hey we're loading and then we start loading our
collection of images there which are being allowed as effects images so they're they're stored in system memory
so they're easy they can be easily uh Blended to each other
I can be easily colored or rotated but they're this the cost from rendering
is slightly slower as they're done with the processor so 50 50 you know
still doing a bunch of setup work on this this image here I don't know what that is the city lights image whatever that
is changing it moving it
what I would actually probably do is I probably have a function right
yeah um I don't know
load message sorry so like message in there put this in
there or something and function and then
together message
now I can just leave that there if I wanted to I probably should move that to the
bottom of the code so it's not really visible to me anymore but then I would have these blocks
and a message in here you know
um what are we Lighting First we're loading stuff first line of fonts first I think it was
uh so we've got a sink inside there too so I'm going to do a screen oh we've got to
clear the screen there actually it just it's when you start the program
the screen is clear to zero so if I draw a text over the buffer again and then do
it for refresh we'll get we'll see the existing text so we don't we don't want that
just clean up as I go through you know my back there and then we can go all right bloating
performance or something lighting fonts uh whatever else we're
doing doing a bunch of work on some images there
uh what that's doing I have no no idea
say about the palette was it
yeah sound effects like some more images
characters it's not pretty to look at but when a first time player is playing your game I have some indication of what it's
doing and it hasn't died we'll just try
well the phone's slowed very quickly and we got through through that aspect there very quickly so
the type the part that's so taking the most time is another aspect of the
loading so we can actually work out to what part of the loading is causing us this delay
maybe solve it maybe maybe we're doing a blending effect on a video image that we
should we don't need to I suspect that's probably the case I don't know excellent I don't know what
those load functions actually do it's probably worth having a look look at though
oh let's go we're gonna have a look
a loading characters
uh sorry I was just rapidly put that through they have a lot of objects yeah okay
those room graphs wasn't it room Graphics yeah
robots
robots and then we uh
yeah I think that's the that's the main part there so if we go back to
like characters no uh we're creating walls
we're at walls we should be on a ticket yeah what functions are costing us
um the most at startup and then
I don't know do a quick save do a run ellipse actually find out
objects all the other aspects there loaded very quickly and they gave us the indication
too hey this thing's working so if worse comes the worst we could go
inside the objects um piece of code and then set it up so that it was
showing us what objective is loading in this case we may not need to do it here
upon to get to the menu you know we might be able to loading stuff
after used to make a selection and then go to gameplay and then only load objects that are actually going to be on
screen I think it's probably the best idea in most cases but uh
it's generally more convenient to do it this way so lighting objects was this lighting
objects retailers having to look at that what are we doing
yeah we're learning uh
yeah we are doing that sorry talk to myself
um a couple of things in there that I always uncomfortable about is one is
that um this duplication of complexity or this
expression that's like this if we just have a thing called file so we make our file name and we go all
right dude do we access in other words is that file on disk
I have ears let's load let's load the thing
the only reason I I prefer to do that is that if I ever make changes to this
expression I would have had to have made changes to the the second expression
it's kind of like what you need to do that for yeah
I suspect this is spending a lot of time doing this because we're doing
we're loading in an image into video memory certainly mask color doing a scale of it
copying the image somewhere else and mirroring the image back I'm not
sure what the performance of mirror images actually like
my concern there is that if mirror image
um if mirror image is
using a lot of Blitz and single strip Blitz to do the flap to invert the image
then that's actually a potential bottleneck in our program that
we might just be able to solve by doing something like this which might seem weird to people but so here we've got
200 plus here all these things here I've got
like this duplicate complexity but okay I've got this one here so right
so we're laying the image here we're creating a duplicate of it over somewhere else
um
and what you could do I don't know I should check if this is a real image
or not but we'll just assume that image
999 doesn't exist right so a lot of that as an effects image
so we want to do let's say the mask color of that or you want to set the
scale of that to where we require and then we want to copy
from that image to that that Target and as well
we want to copy well
if we need that to be an effects image sorry a video image which is what I was lighting before
we probably should do
I'm not sure what we do but uh for the sake of completeness of
like a create image in its place so we'll go hey create
um create image whatever that was n Plus
sorry 200 plus n [Music] yeah make it the width
and size of this temp you know commonly used recycle image
we're going to just thrash around all the time
in other words we want to create an image to be in memory that's the same size as the one we just loaded and scale
up after it's been scaled we want to copy
from
now we want to copy from
sorry um you want to copy for the one that's in
system memory into the ones in video memory and then do a flip of that
and what you probably could do there and you probably should do
if you want to do a flip is do the mirror yeah on this
let's mirror this
mirror image yeah and then copy it down
wow my confusing before yet so for time being we've got three
versions in memory but we don't want to do any pixel level operations on anything that's on video memory because
our system may or may not have fast access to that memory
contemporary systems generally don't all the systems have much better drivers than what they have now because no one
supports director anymore it's like a it's a completely and utterly Antiquated solution
everyone's just gone on to go let's have you know DirectX 9 10 or whatever else
anyone cares about that comes with constraints isn't it you know
just double checking my logic so we're lying lying her in creating the first one copying the effects image onto the
first image of it doing a mirror of the FX image and then
we're going to copy that to this one
all of that trying to avoid doing something in system in video memory
these would be the same I'll bet you know if these mirror functions here well there's a bunch of dark plots there too
I suspect we could you know what I would do is is in all seriousness
I would make a function out of these to load an image and then have it
produce the two scalings or whatever so you could Supply a scaling that you wanted have uh it low into a particular
Source image and they have the mirror be loaded into a Target image as well so
it would say having to do this duplicate sort of stuff here we're doing
because those Loops there are the same for as I can tell it's in the same thing there
what about the scaling scaling's the same so we could just have the same functionality there can play with
um we're just assuming this image here is one that's available to us we don't really care about
I was in memory after we finished loading however if we reload over the index it gets deleted anyway so
this won't solve the speed up problems at load time but this kind of thing absolutely will
here get image status
so I'm not sure what images are loaded into this block here 200 to 200 but if
they're video images and we do we're doing a copy or by making a given with the image for
some reason that we want to do what we're making a gray scale of it for some reason
uh then we're rendering to it we're drawing dots over the top of it every second
pixel so one immediate thing you could do is just
lock the buffer
and unlock it at the end of the process so what's happening now is every time this this Loop steps through
what we got we've got 40 step two about 70 so we've got about 110 70 by 110 it's
a lot of dots to render every time it calls that function it has to lock the buffer draw the dot unlock
the buffer from the system loop back around to do the same thing again it's really inefficient
in this particular case you'd be better off the drawer to draw an image with
the white dots every second color and
then just draw that image onto those it would be much more efficient
but this this will take this is fine um
we're doing it we're loading a lot of stuff into memory in here so that's okay
well lighting more stuff in the video memory doing more copies of it and doing scales of it I think the scouting's okay
I think that's driver related too so in general I would do that process
on a temp image and then copying it to a video image that I wanted for my final
image I would you know use use a system area to do the work on and copy the
video memory when you're done all right see if we've see if we've
broken it
there you go all right
so I've had something if I'll be in there um obviously what I'm talking about is not
rubbish it's a you've got to think about how this stuff is done underneath the hood
and uh doing an image Flip or those things
so it might be the scale image too I don't really know all right
like for all we know this this part of the loop here might have been the part that was causing the huge Slowdown
it might not have been the other the flipping we'll just test it and find out
well there's a good answer there
[Music]
I think we have our answer for that particular thing I still think probably
you know drawing x y
sorry we're doing the across across here but we're drawing vertical columns
wow that's very unusual you normally don't want to do that
because memories non-consecutive when you do that you normally want to do this
in this case there's no there would be a performance
benefit for doing that in PBA but if you unrolled this and uh took this in a bit
further and try to do T flying to the buffer directly and then converted that into PV to dll then you
would the performance benefit you would get is enormous but nonetheless
all right so we've we've tweaked the loading we haven't fixed it I think we could probably get
this to a point where it loads you know within within the first second and quite comfortably by the looks of those things
I've got some data being read from the end of the program which is
help files is it
I tend to be a stickler for things like text inside applications
um I try to have that externalize as much as possible and one of the reasons
for that is is you can update the text outside the program
uh have other people write the text for you Etc and
possibly if you wanted to have language conversions for those dialogues you know
nonetheless let's go to start we'll tackle the main the main Loop
so we're loading our sounds that's our open screen let's have a look at that code subroutine
seeing a volume
oh that was one thing I did find a bit strange is we're doing
um it's kind of hard code to run for the joystick or the control key which I find is an unnatural key for a
so initially I had no idea what was happening oh there's another one there
these kind of if you wanted to have hang on what we're doing there
unroller so we're drawing we're drawing in color zero in the Black
version of this text slightly offset from the other one so that we're drawing a shadow of this text
that's what this is that's what that's doing
um I would always do a make a function out of that it's it's not that this is
complicated right it's these little subtle changes you
might make the subtle changes in other parts of program you've duplicated piece of code to do this so you end up with
this kind of extra complex definition
yeah so you might have a function that uh that does this little part here
uh you know draw you know shadowed
message I don't know what you call it but who knows
so message goes passing it through pass it all passing it through
and the other reason why I like to do is this particular kind of thing is that we
can do something that this routine doesn't do
we can restore uh
back someone um what I mean is that we when we call a
function put that the location there actually
I just have y position there and we'll just make this a fixed offset white pause plus four
this will just be a white horse there
yes inch
I'll get back to my point there in a second so uh 350 was it 350 drug there
do that thing there oh sorry wrong
it's a comic character not the comma character there we go so we I would take
that out um
even the message there so I actually would make
and I refer to my story making a wrapper and the point of that
is sorry um
so we can dance simple logic or repetitive little blocks of code like this
into something that's safe so when I call this it it doesn't change the state
I guess that means I can I can call this anywhere in my program and it's going to draw me
this scented pastel sorry extension message
on the screen for me in this particular color in this font through and then it's
going to restore the font back to what it was was after I write or I call it
so I can embed this anywhere I like I don't have to worry about what comes
after it or what what's the state of what's happening before should never have to bother yourself
with those things I know and I kind of sound like I'm picking on that but uh
there's lots of these little bits and pieces as you get used to doing this stuff you go oh I can make a little function that does
that behavior and that becomes part of my own my games API it's like well if I
want to draw a shadow you know fight in font one or whatever
I might have a you know I have you know rent
a function called our print shadowed something like that and then
have something like that and it you know rather whereas or is it and where and that's
been implemented behind the scenes where I've done multiple print statements and chains of fonts and done whatever I need
to do with it but when I'm using the code throughout my frame I just calling this simple function to do that task
because we're still back to what it was
the goal of this is to make all of these subservient codes simpler
they you know have less of these little Collision problems that pop up in programs you would not believe there
were times that modifying global global state in a program causes an undesirable secondary
effect it's just crazy well there's a weird way on there we've
got we're clearing the screen all of it and then we're drawing over everything anyway
and we're drawing a box towards the
yeah they're drawing an image over the top as transparent why would we do that
I tend to like if you look at a lot of these a lot of retro games at the moment you'll find
small bits of motion make the world a difference to the presentation of sort of how it feels to you when you're
applying it it doesn't have to do you know back flips and who knows what just
slight movie and a slight push a slight shift a slight fade I mean who knows what you want to you know decide to do
but it makes it all feel alive and active anyway we'll just run it again see if we
haven't broken something stupid um [Music]
it seems okay getting back to the Gameboy let's talk about the game let's
find this game Loop up here
uh yeah let's look at this this Loop earlier I think that's the loop that's the
drawing Loop inside the game Loop so we are back to the top oh page our way
down through it the actual method of how this game works I have no real idea
make doors change room do yeah this is
the main Loop
I don't know what that does change your room I have no idea
so so entering in my lip I assume this is the main Loop
um blessed branches off somewhere else but
um so we're clearing the back buffer to zero RGB zero doing our draw a room which is what we
just looked at before I don't know what the rest of this is doing
sector something rmx is some sort of global it's carried through
WL workload Maybe not sure or work loop I guess maybe
oh no war lasers perhaps have made their maze fire laser killed
I've got a huge white in the middle of that there we're not actually doing anything
right try all this right all right so we're drawing Sprites
combination of drawing images and Sprites like I thought it was going to be using
a captioned scene I was a bit worried about that but we're not doing that
or physical example there I've got our we're rendering a message with all the
code unlocked sorry unrolled in place to do that we just make a function
make a function and have a have an in color supplied to it or whatever and just be done with it
right so once we've drawn all the Sprites obviously the game is drawn at that point so what's the stuff here
doing it's like dialogues so if we're dead all right if the dude's dead
it's all game over Loop oh there's one there repeat until Joy
button equals true which means I'm going to joystick plugged in so if I end the game I won't be able to
continue the loop
probably sh so this is one of those areas there when you shouldn't do that um in all seriousness
this creates uh a hard Loop where now your application is
sitting there running flat out for no reason I would put like a weight
in those loops foreign
a couple milliseconds
um that means the program can't max out the CPU while it's sitting there and
which you're always will just hate that in general
but all the stuff down here is to do with messages and
status bar there for example and so I'm shooting this Sprites here for different
like hard to level effects or something like that I don't know
I've got to wait there then yeah
that really shouldn't be overtime okay
it's a draw room let's I'll do a quick save back
let's go open Russia I should say draw a room
yeah I like you've got a header it's nice
a draw image there drawing Edge there hmm
who knows what kind of images they actually are so I don't know what this what these images did are they what
they're doing and while we're drawing them I have no idea
some dense complexity in here and this is what I noticed before these texture quads
my gut feeling about this inner loop is we've got a mixture of
rendering images from video memory which I suspect these are
uh and these here are done with software
bleeding texture quad which needs buffers locked and then unlocked again
if you have a loop through you draw an image and you think all that and your
driver supports asynchronous rendering which all in the old die so they all did they're all fantastic at this stuff you
could just pass off into there and your Cobra keep running even though the draw hasn't even happened yet
that's what I sequence rendering is all about uh trouble wise is if you
if you want to try and manipulate the surface this image has been drawn onto which is the screen
before this image has been drawn it has to be locked and waited for which can take
which then takes the length of that time so there's no
benefit so detriment actually can be quite detrimental
what's all the texture quad stuff or stops down to five
I wish I knew this was doing more than what I do that's right above where I was
before um
you know what I might do is I might I might wrap your image for a second
what I mean if you're not sure well what I'm talking about is I'll make a little function
um a safe dry image whatever
I have all the same parameters this image and it's going to be X
position its y position and it's Flags
transparent flag generally and function
now what I want to know is I want to know
if the image has been drawn in here are video
or not
if I do a draw image sorry for our image we're just passing
those parameters straight through into it over here get News Talk thanks
image sorry this image
don't remember the flags on top of my head so let's look at the help go straight to help
if it's one it's a video image that was a store in GPU memory
yeah you might think that means that's good that's good if you want to do GPU level
copying between on the Nvidia memory side but if you ever need to do
a mixture of the two that's a real problem
it's just things have changed over time you know these days everything's just done with a GPU and it's done with a 3D
Hardware there's no 2-day Harbor at all you know I mean that's why it's become so it says it's a
problematic for drivers they just don't buy supporting it all right so so if this is uh equal to one
in other words I'm just putting a query in here going are you a video image
quite reliable uh video
inch count it's a good debugging junk really
at the start of this loop I just I just want to know how many of those we're we're doing
yeah so it's safe I probably should put
parentheses around those two
user functions and tell commands have slightly different rules
that's something I love but uh it is a theme
and device
it's texture qualms in there somewhere I've got a sound flying out somewhere much there okay
there's some Sprite positioning as well so they're not being drawn they're being positioned
that's okay so they've been drawn in that there's a call to draw ordered Sprites
so that's probably the characters I think it would be the characters
I don't know um in text
at uh 500 400 and then
video image sorry count
plus string going into that thing go into that thing yeah
do we miss any draw images
see texture quad we should do the same thing there too but I'm guessing that they will all they'll definitely be
effects images
uh I don't know
just bump that we're just embedding a bit of debug
logic um just to get a bit of a sense of what's Happening
no
why that's a pause I deliberate pause
okay that's snake this same as no video images
so the drawing in that Loop and not video images to begin with
there must be effects images if that's the case
then anyways familiar with uh let me just lock the whole buffer just
lock it at the start excuse the uh Sirens the background but where I live
now is very very near a major arterial Road and there's
all right
straight away set the speed of the objects rotating now
clashing with the character but he's moving much faster everyone else is
moving much faster too so that's our problem
hey stop shooting me dude
it's very cool I like it
I'll bet those lines to the same problem seeing that when the robots are firing
out there's like a like yeah it's like a weapon there too
and that's that before
some other ones there so check this out sit see how it's drawing
down the bottom there with a oh
okay some of the lies is coming out
there's a shadow on the floor I bet it's doing a blend against the
video memory to do that
ice look I suspect that probably the best way to do to do this game in general
is to have an artificial full screen effects window
render the whole thing to the effects window and then just do a copy down
that means that modern systems will be able to Crunch that data easiest pie
you've got no driver restriction problems at all in fact you're not even using direct draw or doesn't mean matter
from what version you've got installed
anyway those lines let's assume that that's fixed that
problem all right draw a room
wall lasers finalizer lost active
I wonder what that actually is no but okay
we're playing a sound
regardless if it was if it was just played probably shouldn't have a delay on that
um but yeah the Loop's doing this what we're just talking about before it's
drawing a bunch of lines
it's not something not doing a blend it's just drawing two of them there so let's just do
unless the ink mode sets somewhere else that may be the case
sorry it's been locking up like it uh the
start of this batch and then unlock it at the end of the batch something weird there too
if we're falling let's not do those things only do that if it's actually
if they're actually doing something
stand there and um
running an inspection with a circle is yes it's not massively complicated for the
wrong time you're doing a bunch of that stuff it all adds up you know
so here we're talking just to pre-check to see I think that's a falling flag I reckon
are we falling outside of the world Maybe I don't know what that is there I have
no idea but if there's two cases here are not
false are both true then we go and we check
for intersection with this circle whatever that circle is I have no idea
a bunch of ellipses there as well so
I'll buffer unlock buffer quick save again oh
quick save quick run just search for lines
[Music]
if you look at the shadow under the under the characters there
I'll bet that's Alpha Blended against the ground and that that does require fetching back buffer and that's very
expensive that's cool
before we go checking that stuff we'll deal with a search for line C
platform I don't know what that's doing but we'll
put a lock it will unlock it at the end
because each one of those locks and there's you know it's 10 by 10 so 120
locks there's two two lines Perth so there's two locks per Loop
you know even if if each one of those locks takes half a millisecond
but that's the whole frame you can lose just in in doing those locks that's not the line drawing that's taking that it's
the request to the system hey can I draw to the buffer now please that's how frustrating this stuff is
behind the scenes well there you go so one point it was
actually using a cat uh a camera of some sort
wow what the hell is that doing I just don't know what any of this is doing
um came in you're more welcome to in whiteness
Sony key values too like there's certain values that represent certain things to
do a search again find this thing okay
got one line drawer there yeah not the end of the world
that's why we want to catch situations where we're doing a collection of Brute Force stuff to a
surface I think it might be the only one
there's a couple of situations there that's cool it's fine
I saw this Lane loop again we've tackled drawing the room
it's fine throwing a laser are we killed are we move robots
burn if burnt over this then decrease life
set a bunch of properties up in here wait a period of time delete Sprite one
it must be the player Sprite one
um well there's an interesting one there if
right one's the player which again Sprite one
doesn't exist Hezekiah yeah what images is it currently using
is it bigger than zero in other words does that exist as well it's possible if you have a Sprite with
no image but it's probably some buggy behavior in old versions of people if you do that
copy image so we're copying it to somewhere else
we're changing the image there we're doing a lighting of that
hmm if you want to change
the coloring of a Sprite there is actually a draw mode to do exactly that
I probably should work out what kind of sprite scenes You've Got Each one set up to be there before we talk about that
but you would this is a distracted process we're making a copy of the image this might be in video memory
who knows um make it the standard Sprite and then
when you write an image it has to read those pixels from the image so that's why it's important that those things are
not stored in real memory if you had if you had a secondary copy
of all of the player Sprites as effects images that you just use
and you have they have another single Sprite that's in Via memory you'd save
yourself a bunch of video memory as well so we run all the systems even older
than what you might expect uh as well as modern systems which very few
engines these days will do both in fact I can't think of anything that do
we have problems with that because you know contemporary systems don't like Legacy approaches you know but you still
can make it you can make it work to a point where someone can sit down and play a game and have a bit of fun with it you know
but what I'm saying is that this you might have all the Sprites still in memory as effects images and then as you
need to change Sprite so you don't just change the index you copy from the current Sprite required into the one in
video memory but if you ever need to do uh to manipulate the image like this you can
do the same process but in the version that's in in system memory and then copy
that down which means no fetching for video memory no locking buffer problems none of that
stuff will go away
there's dance bar there a couple of Shield boxes
um well there you go that's
that's the same issue there isn't it if you do if you're trying to Alpha blend
something with a backdrop um you're going to fetch that data from video memory to blend that down
we could we could have a lock around these
all of these little little Twigs but not nothing they're
they'll help iron out performance for not just on my system but on most systems
because that's all we can really do is try to make it work for most people
what's bevel box yeah okay
we're drawing a bunch of boxes and quads and whatever let's do a lock on that
[Music] status status bar that's what it was
so we've got to lock around these uh we can't do this around the tax
buffers and the reason for that is we I assume this is just using GDI text
um which has to fetch on the back buffer as well all the same problems exist with
this but it's reasonably optimal um
but if you try and lock if you try and write text to a lock
buffer it'll just throw up at you pretty much
uh I still have to put up with those you can get around that stuff by using Sarah
fonts but that's another conversation just means reading the documentation understanding what that means
um in my experience almost no one has ever read it and got it so this drawing image here
um set font set font text drawing the score
drawing keys I don't know what any of that stuff there is doing
right
I think about that understanding there [Music]
is performing pretty well there um
nothing there okay
get out there well
I love the pinball games over there
hey stop killing me dude
we might have to sort of leave our session there um they've been talking for an hour anyway
the general problems that tend to be is this locking and unlocking buffer you know
what kind of image are you drawing and where you're drawing it to if you never need to do blending between things
blending it off the screen and then copying it down is always the best option
um in many cases you can actually do a lot of that work up front and then just show the resulting image afterwards
uh if you wanted to do well I don't know the thing I started
talking about before about having the player Sprites stored as effects images
and then have them maybe flipped or whatever you wanted to do and then uh
have maybe you want to have some sort of processing effect on them as well
you don't either do it on all the Sprites you can just apply that to the Sprites being drawn and then draw over the top of it and then copy that to to
if you need to do a video Blitz my general advice is if you want to run
on anything contemporary I mean or you know Windows 8 10 11.
um I would stay clear of video images in general
and that doesn't mean you have to sort of you can't use both it's perfectly fine
to to write little wrapper here or there and that does that job
you know like uh like rather rather than use
where are we there rather than you know use the load image
directly for example have a little function you know that you know
my low image or you know my
load game meters all that have your phone line maybe you your uh your index
of the what slot you want to load this image into that's how you want to work
they internally you might check to see you know if
you use video image is upset to true or something like
that that would use load image
you know so you can kind of distill the logic for
reading and writing media into these kind of common functions yourself and then you'd have to maintain them out
throughout the whole program yeah so say you could use that approach
to sort of to separate yourself from the from the behavior of the Intel command sets
that's what rappers do uh before I go this had a very
interesting idea about um signing preferences
check this out so in order to save what's going on
so having a screenshot there as well I think yeah okay
um even this quick gradient this image is creating video memory
which means we've got heaps of lock buffers occurring on that VMware image for no real reason this could just be
an effects image now we don't have any of those issues whatsoever
we probably should have locks around these surfaces but yeah I don't care enough about that
um because I know the process of locking those buffers is is not as intensive as
what calling the director or lock and unlock process is
but what this does is it makes an image and then stores the data that has been
if we were up to in the game it still says pixel data
it's possible because these colors are just 32 integers so our color is nothing special it's just one sign integer
32-bit integer as long as this image here is 30 to bit that works perfectly well
we only file if you want to run this on an old system that didn't have 32-bit
um I only had like a 25-bit display card or 16 bit just like a 15-bit display card in that case this will generate
if the game's running at 15 bit which if if you request those a bit up
front and it fails it will try 24 bit then try 16 15.
if they all fail then the game's not going to run anyway the person hasn't got a graphic card that we
can even run on if one of the one of them successful and it's not 32-bit then this this actually
will fail what you probably shouldn't do is
there's a secondary command there called standard which has like a a bit a bit depth
um as part of those and then that would run regardless of what the this crazy image that's the use
of it in system memory and it does not matter one iota about what the current screen mode
actually is whereas normally an effects image is the same bit depth and bit
format for its RGB as the screen is so it doesn't so you never have to
translate anything on the Fly that's the reason for that but this is pretty pretty cool uh so
creates an image and then stores the player's data on something that you can then load into
a you know your paint package and see the data visually
like normally with a battery file you can't really say this out for if you have a text file
I probably would do this a bit differently here I would have a wrap around this
um you know except you set you have like a right row thing and then just have a
list of these things in order and then so you don't have to worry about what these order actually is
see then you can preload the thing as as the opposite if you wanted to
if you get what I made anyway I mean km knows the ins and outs of the program I don't I'm just picking
through and uh trying to make sense of what I can see anyway uh thanks for
listening to my ramble uh sorry it's so long and uh Run Run the game one more time
hopefully he can't get some hopefully came in and get some ideas about how to to move forward and Tackle
bringing whatever changes he wants to make to the game okay moving forward and uh
it's a very impressive passive software I'm it's the usage of the things it's
always interesting to watch how people use the command sets that are available to them what they how they favor things
how they favor other other approaches it's always interesting hopefully some of this has been useful
none of this has been intended to be a derogatory in any way it's just me
trying to give advice that as easily as I possibly can by looking at the program I'll leave I'll leave this there came
in's done a fantastic job come and check out his work on the Press progress in the forums check out his hio
Pages check out you know the videos we've made Etc
uh and give him some love thanks for watching and I'll see you
next time bye thanks for watching and if you want more programming content please subscribe to
playbasic.com

 

Kman1011

Thanks to all for the tips.

I'm going work on getting some improvements to the game.


Quoteif i remember correctly, copy these 3 dll files from the folder that has the version of playbasic you are using to make your game (this is important).

Stevmjon, I'm curious to know what these particular files do.

Hey Kevin, Thanks for muddling through my code trying to make sense of it. Must have felt like a CIA agent deciphering a Russian code transmission.
Thanks for the input and suggestions on improving the code. My takeaway from this, is that video is costly in terms of programming. Locking & unlocking buffers is certainly a useful tool when you're
trying to get as much graphics without to time to process it.
I know if I looked closely I could find some redundancies that could be converted to functions.

I watched the whole video so I thought I would explain a few points.

Dim Obj(22000,8,8) As Object

That can't be right. I'll have to fit that

I liked the loading routine. I have something like that in another game but just shows bars so , yes to show it has not crashed.

I noticed it ran it slower, I'm guessing you're using a new version of windows. I run on Win7 so it's quite a bit faster but much slower on my newer laptop running on Win11

Fist thing I would have done was delete the 'Wait' in the main Routine I found at the end  of the Main loop



Sync
Wait 10
Loop


I would like to point out that the shadows on the robots are also collision detectors. As a matter of fact, all the furniture has collision detectors which reside under the actual
sprites.

Now the 'drawroom' routine and seeing it running in the main loop made me realize that there is probably a better way to handle that routine. The robots and Furniture should
be the only ones needed to be updated. Could the background be drawn as one image?

Wasn't sure if you noticed you could press F1 for help on the opening screen

'Changeroom' - makes to changes needed when exiting and entering a new room

When the character flashes at the beginning, it indicates that he is shielded temporarily. Cannot get zapped or fall down openings in the floor.

I have added an image map to help as a reference get an idea of the graphics and locations

Here is the sub code

Psub drawimageset(image)

Cls RGB(255, 255, 255)
SetFont 1
For y=0 To 25
For x=0 To 24
Inc image
If GetImageStatus(image)=true
ScaleImage image,50,50,1
DrawImage image,x*50,y*50,1
SetCursor x*50,y*50
Ink 0:Print image
EndIf
Next x
Next y
Sync

Repeat
Until EnterKey()=true
Sync
savebitmap "images.bmp",0
WaitKey
EndPsub


Anyway I appreciate the help and I would be interested if you saved the updated code.
Ahh... Another visitor. Stay awhile....STAY FOREVER!!!...MWA-HA-HA-HA

stevmjon

#25
kev will know what the DLL files do, as far as i know if you place these files in the the same folder as your saved program, then the game .exe file you made won't have to search for these DLL files because they are aleady in the game folder. i think it is when your DLL files are not in the same folder then the game .exe needs to search for them and this is what anti-virus software deems as 'suspicious behaviour' and quarantines your game.

you asked if the background can be draw as one image, yes it can. you just need to create a screen sized image (prefer FX image), draw your background graphics to this FX image, then when done draw this FX image to the screen.
kev can probably apply this in the code if he uploads the updated code.

also, you are using an older version of playbasic too. there is at least v1.64P4, and if you wanted you could get the 1.65x newer version... i use 1.65 and it is faster than v1.64.

did you know that you can have multiple pages for your code, instead of 1 large page, by clicking the top menu "manage source files" and adding as many as you like. even change their order too.
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

kevin

#26
 Kman1011

 
   
QuoteStevmjon, I'm curious to know what these particular files do.

       Everything..    When you build an exe all the parts are linked into your EXE..  When the program is run; the components need to be extracted in order to run.   That's generally fine for older editions of windows, but such practices can run rife of antivirus and windows itself with write permissions..    

      Solution just copy them to your ExE folder can it'll trick your EXE into thinking it doesn't need to extract them..  


   
QuoteHey Kevin, Thanks for muddling through my code trying to make sense of it.

         Nah it's a fun project to look at, but would some comments have killed ya :)


   
QuoteLocking & unlocking buffers is certainly a useful tool when you're trying to get as much graphics without to time to process it.

         Well it's part of drawing process.  You can either do it yourself and minimize the impact as much as possible or just let the commands do it internally.   You really can't avoid it, just manage it.    

          Emulation Of How Buffer lock and unlocking works in graphics commands


Quote
Now the 'drawroom' routine and seeing it running in the main loop made me realize that there is probably a better way to handle that routine. The robots and Furniture should
be the only ones needed to be updated. Could the background be drawn as one image?

      Yes I was thinking the same thing actually.  

      You could selectively refresh the backdrop.  Doing something as simple as drawing the floor tiles out to the static picture,  so the redraw is just drawing walls in order.    

       GetSpriteRect Example (Dirty Rectangles / Selective Map Refreshing)



  Download

     attached bellow is the edited code from the video above.

Kman1011

#27
New update on my game on itch.io


I added the DLL files like Stevmjon suggested and got rid of a number of useless folders and files only used in the full version

Thanks the everyone's help I got a decent version up and running esp. Kevin for going through the code and finding some shortcuts to get the game to run faster.
It runs stupid fast on my Win7 laptop so should run a lot better in Win 10.

I found that Draw_Shadowed_Message function pretty useful. Was called up an number of times in my code

Just added a few more parameters


Function Draw_Shadowed_Message(font,Setink,Ypos,Message$)

SetFont font
Ink 0
CenterText GetScreenWidth()/2.0,Ypos+4,Message$
Ink SetInk
CenterText GetScreenWidth()/2.0,Ypos,Message$

EndFunction


Also added commenting as Piamoo wrote:
QuoteIf there is no messageboard, how can visitors who like your game write down "Excellent game!", "Well done!", "The game looks interesting!", etc.?

Yeah I'm sure that's they will be saying  ::) lol

Hoping I can filter out negative comments. Just keep ones that bring up bugs an errors not ways to change the game.



Anyway If you want to check it out. Here's the link & have fun.

https://kman1011.itch.io/operation-watergate

Will be working to get my next project up and running but still needs work to get there.

Till then, keep gaming!!

Ahh... Another visitor. Stay awhile....STAY FOREVER!!!...MWA-HA-HA-HA

kevin

#28
Kman;

     Glad to hear it's moving forward..    

    The point I was trying to make in the video,  wasn't hey use this code; but rather,  that this type of code can be broken down into smaller helper functions that we can call universally to perform particular tasks.    The benefit is that then we have one place in our program that does that particular thing.  

     One thing to be careful of which does case bugs in peoples programs is changing the global state within a function and not restoring it.    If we run this code bellow we see the global INK and FONT state were altered.  

PlayBASIC Code: [Select]
   loadfont "Arial",10,50

Do
cls

setfont 1

print "Hello World"

Draw_Shadowed_Message(10,$00ff00,200,"This is my message")

print "Hello World"

Sync
loop spacekey()


Function Draw_Shadowed_Message(font,Setink,Ypos,Message$)

SetFont font
Ink 0
CenterText GetScreenWidth()/2.0,Ypos+4,Message$
Ink SetInk
CenterText GetScreenWidth()/2.0,Ypos,Message$

EndFunction






       It's generally better to preserve the existing state of something global if we're going to briefly modify it in our function.  Which can cause unwanted side effects in programs later on.  

       In this version the default INK and Font are preserved so the PRINT statements are unaffected by the shadow call.

PlayBASIC Code: [Select]
   loadfont "Arial",10,50

Do
cls

print "Hello World"

Draw_Shadowed_Message(10,$00ff00,200,"This is my message")

print "Hello World"

Sync
loop spacekey()


Function Draw_Shadowed_Message(font,Setink,Ypos,Message$)
oldINK=getink()
oldFONT=getcurrentfont()

SetFont font
Ink 0
CenterText GetScreenWidth()/2.0,Ypos+4,Message$
Ink SetInk
CenterText GetScreenWidth()/2.0,Ypos,Message$

setfont oldFONT
ink oldINK
EndFunction







Kman1011

#29
Yes I know, but I did see your point. This code was useful in a lot of ways because I called it up number of times just like Bevel_Box()

I see what you are saying but it's always my coding practice to set colour, fonts. etc before you use anything like print, line or any graphic, that way you don't get those undesired effects like a wrong colour.
It seem to. work for me. I don't think there would be any slowdown with this method.

However I now have a new issue

Getting error message 'User lib function not found' when I run the .exe application file.

I added the lib files in the working folder that this program uses, but still get this error. Do I have to place them in a certain folder on my drive or are there other files it needs?

Has anyone had this issue?
Ahh... Another visitor. Stay awhile....STAY FOREVER!!!...MWA-HA-HA-HA