Help Wanted

General Development Screen Savers Part 1a and b Help thread – Mene-Mene

Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
I personally need some help making a screen saver for my father as its tomorrow. I've semi started programming it in Blitz Basic, I'm just missing a couple elements.
Current Code in BB:
Edit 2: Cut out for length reasons.

That's the start anyway. Basically it picks a random word between the available words, splits it up into letters, and sends it going down the screen. But it goes both ways, and when the first letter hits the bottom of the screen, the letter that was going double speed, now goes normal, and it switches.

That's my Idea, take it if you want, I don't really care what you say, except just report how it goes.


Anyway, I want to at least start with Screen Savers, and so I'm using Brian's article. Wiki doesn't have anything on making them. Googling it, all the recognizable sites give you nothing, and I'm not brave enough to go to sites I don't recognize.

So to begin, I googled MSVC 6.0 and discovered it was Microsoft Visual C 6.0. Okay, so I downloaded the only available version, Microsoft Visual C++ Express. Great, looks nothing like his, and looks difficult to manage.
So my first request would be a compiler I can use for this. Is it possible to use BM for this?

Edit: BTW, the code looks nothing like the screensaver. While waiting I'm making a better Pseudo-type

------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto
I reserve the full right to change my views/theories at any time.

[This message has been edited by Mene-Mene (edited June 16, 2007).]

[This message has been edited by Mene-Mene (edited June 16, 2007).]

SSquared

Member

Posts: 654
From: Pacific Northwest
Registered: 03-22-2005
Wow! That's a terrific idea!

There is a sample Screen saver included with Visual C# Express and Visual Basic Express. Does not come with Visual C++ Express. It is an RSS reader, but I think it also includes how to draw and move text.

You may want to give those a try.

Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
Thanks for the info. This is almost theater-like. A child 12 years old, has been using computers since a toddler, making games for 2 years. Attempt to make a complex feat with a language just learning, never done graphics in it before, or a screensaver ever....

lol. Any help with anything would be awesome.

------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto

I reserve the full right to change my views/theories at any time.

SSquared

Member

Posts: 654
From: Pacific Northwest
Registered: 03-22-2005
You are only 12?

Let me know if you have any questions. I think the sample may have what you need. Just delete the code regarding the RSS functionality.

Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
Yeah, I'm 12. Started at 10 though. Started Here at 11.

A question, I've downloaded the C# thing, and attempting to learn. Is it basically any ordinary application but with a different extension? Does changeing the extension change anything with the program?

------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto

I reserve the full right to change my views/theories at any time.

[This message has been edited by Mene-Mene (edited June 16, 2007).]

[This message has been edited by Mene-Mene (edited June 16, 2007).]

SSquared

Member

Posts: 654
From: Pacific Northwest
Registered: 03-22-2005
I'm not sure I understand your question. Are you referring to the .CS (C Sharp) extension or the EXE/SCR extension. C# files use the CS extension. The built application has a .EXE extension. When you are ready to install it as a screensaver, just change EXE to SCR and you can then use the Windows Screensaver to run your application.
Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
Thank you, I've gotten the Screen saver part mostly worked out then. Um, I'll be working on the program.

------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto

I reserve the full right to change my views/theories at any time.

Briant

Member

Posts: 742
From: Stony Plain, Alberta, Canada
Registered: 01-20-2001
To answer your question about the articles: although Visual C++ 6.0 was used for the article (and code), it should be a very simple matter to use the code in 2005 Express. The screen shots would have to be updated, but the settings would be the same too, just configured in slightly different places in the IDE.

You're the only person in about 3 or 4 years that has commented on or asked about the articles (that I know of), so that's why I didn't spend any time updating them yet. Let me know if you have any specific questions and I'll help you out - but I don't know really anything about Blitz Basic or Visual Basic.

------------------
Brian

"OOP programmers have a lot of class"

Check out this webhost! Fantastic prices, features and support!

Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
Thank You BrianT! I found the setting in DevC++. Here is the Pseudo-Code Updated:

;Screen Saver: Fathers: Pseudo

Graphics 800,600
SeedRnd MilliSecs()
SetBuffer BackBuffer()

;Number of words
Global numwords = 1
Global Y = 13
Global X = 8

Type AcWord
Field Together$
Field Letters$(7)
Field NumLetters
Field CurLetter
Field Direction
Field X
Field Y
End Type

Type DoWord
Field Together$
Field Letters$(7)
Field NumLetters
Field CurLetter
Field Direction
Field X
Field Y
End Type

;List of Words
Dim Words$(numwords)
Words$(0) = "Loveable"
Words$(1) = "Generous"


Repeat
If KeyHit(1)
End
EndIf
;Across first
For Loop_Var = 2 To 47
;Get Word
RandChosen = Rnd(0,numwords)
A.AcWord = New AcWord
A\Together$ = Words$(RandChosen)

A\NumLetters = Len(A\Together$)
For LoopVar = 1 To (A\NumLetters - 1) ;Flag
A\Letters$(LoopVar) = Left(Word$,LoopVar)
A\Letters$(LoopVar) = Right(A\Letters$(LoopVar),1)
Next
A\Y = Y
Y = Y + 13
Next
;;Do Stuff
Ac.AcWord = Each AcWord
Text Ac\X,Ac\Y,Ac\Letters$(Ac\CurLetter)
Ac\X = Ac\X + 8

;Down Second
For Loop_Var = 2 To 50
;Get Word
RandChosen = Rnd(0,numwords)
D.DoWord = New DoWord
D\Together$ = Words$(RandChosen)

D\NumLetters = Len(D\Together$)
For LoopVar = 1 To (D\NumLetters - 1) ;Flag
D\Letters$(LoopVar) = Left(Word$,LoopVar)
D\Letters$(LoopVar) = Right(D\Letters$(LoopVar),1)
Next
D\X = X
X = X + 16
Next
;;Do Stuff
Do.DoWord = Each DoWord
Text Do\X,Do\Y,Do\Letters$(Do\CurLetter)
Do\Y = Do\Y + 13

Cls
Flip
X = 0
Y = 0
Forever

I've got the make it into a screensaver part, but not the commandline, and change it into C++ part. I've never done graphics in C++ before so I'm having trouble. In the 2 languages i know, I can't set the extension.
------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto

I reserve the full right to change my views/theories at any time.

[This message has been edited by Mene-Mene (edited June 16, 2007).]

SSquared

Member

Posts: 654
From: Pacific Northwest
Registered: 03-22-2005
If you plan on using C++ Express, don't forget you will also need to download the Win32 SDK: http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/

C++ Express is meant for creating .NET applications, but by installig the above package, you will be able to use regular ol' Win32. You will need this to match Brian's article. Win32 is Microsoft's C API set for creating Window applications. They later created Microsoft Foundation Classes (MFC) as their standard C++ way of developing. And now they have .NET.

Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
Ah, that would help with his article. I'm still really blank on graphics.
This is basically what I need right now. I used BB in order to write some pseudo code for the actual C++ code. I'm pretty much past that part, but I've never done graphics before, so I need some help with that, and I don't understand how to exit with moving the mouse. I also don't quite understand what window. I tried to learn what I could from your example but I'm kinda stuck, any help would be great.

Do I need to make a Win32, or does it work with something else?

------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto

I reserve the full right to change my views/theories at any time.

[This message has been edited by Mene-Mene (edited June 16, 2007).]

[This message has been edited by Mene-Mene (edited June 16, 2007).]

kenman

Member

Posts: 518
From: Janesville WI
Registered: 08-31-2006
Did screen savers in VB a long time

Make your .exe file

JUST rename the extension .scr

OPening in the display control in the control panel and you are done.

Best o luck to ya!

Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
I tried doing that, but It will only create what my anti-virus calls, a hidden-extension.

Oh, I just had the hide extension on.

Fixing up Pseudo-Code to be in BlitzMax since I can't handle C++. Here's the latest:
Edit 2: Cut out for length reasons.

The line in bold is causing problems, its trying to convert a string array to a float, and i don't know why.
------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto

I reserve the full right to change my views/theories at any time.

[This message has been edited by Mene-Mene (edited June 16, 2007).]

[This message has been edited by Mene-Mene (edited June 17, 2007).]

SSquared

Member

Posts: 654
From: Pacific Northwest
Registered: 03-22-2005
I still think you should use the C# Screensaver example. It's complete. Wiggle the mouse and it goes away. It has everything you need.

Take the example and change the following code. In the file ScreenSaverForm.cs, there is a method called OnPaint. Replace it with this:


protected override void OnPaint(PaintEventArgs e)
{
String[] text = new String[3];
text[0] = "Great";
text[1] = "Terrific";
text[2] = "Fun!";
Random rand = new Random();
int choice = rand.Next(3);
int xPoint = rand.Next(600);
int yPoint = rand.Next(800);
e.Graphics.DrawString(text[choice],
new Font("Verdana", 25, FontStyle.Bold),
new SolidBrush(Color.BlanchedAlmond),
new PointF(xPoint, yPoint));

//rssView.Paint(e);
//rssDescriptionView.Paint(e);
}

Just comment out the RSS code. The background pictures are actually quite fitting for Father's Day. The above code will actually draw the items rather quickly. To fix this, create member variables to hold the choice, xPoint, and yPoint. Then, create the random numbers in backgroundChangeTimerTick (the method just below OnPaint) and continue to call DrawString in your OnPaint, but use the member variables in your call.

For some added effect, you can uncomment rssView.Paint or the other one (if you want). Then, right-click on the 'Paint' part of rssView.Paint and select 'Go To Definition'.

In Paint is DrawItemTitle. Right-click and go to definition. There is a for loop in there with the comment //Draw the title of the item. You can use this as a place to type in some bible verses.

Anyway, just some ideas.

Let me know if you have any more questions. Hopefully you can get this done by tomorrow.


Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
I don't know C#, so it looked especially foreign to me. And I'm not really looking to make him a fathers day screensaver, but rather one I made.

------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto

I reserve the full right to change my views/theories at any time.

SSquared

Member

Posts: 654
From: Pacific Northwest
Registered: 03-22-2005
OK. I don't know BB, so I couldn't help in that direction.

In any case, I'm sure your dad will enjoy it. Like I said, I think it's a nice idea! Have fun with it!

Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
Thanks!

------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto

I reserve the full right to change my views/theories at any time.

Briant

Member

Posts: 742
From: Stony Plain, Alberta, Canada
Registered: 01-20-2001
Hey Mene-Mene,

I'll help as I can, but remember I'm not a Blitz or VB programmer. I can look some stuff up on blitzbasic.com, but that's it.

For exiting by moving the mouse: at the beginning of your program, get the current mouse position like this:

origMouseX=MouseX()
origMouseY=MouseY()

Then, I would add something like the following to your main loop:

button=GetMouse()
If button <> 0 Then End
If MouseX() <> origMouseX Then End
If MouseY() <> origMouseY Then End
value=GetKey()
If value <> 0 Then End

In other words, all you're doing is detecting if the mouse buttons were pressed, if the mouse moved, or if a key was pressed. If so, then exit the program.

For graphics, I would use something like DrawImage. There is a good simple example at: http://www.blitzbasic.com/b3ddocs/command.php?name=DrawImage&ref=2d_cat . In this example, the While loop at the bottom is where you would put your mouse movement detection stuff.

------------------
Brian

"OOP programmers have a lot of class"

Check out this webhost! Fantastic prices, features and support!

Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
Thank you for your time. I was actually C++ in finding difficulty in graphics. I didn't notice the function you mentioned for getting any key, thanks! I was actually wondering before if there was a special thing for screensavers, but from the context of your message it seems to say otherwise.

This is the new code, still stuck on that error.
Edit 2: Cut out for length reasons.
------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto

I reserve the full right to change my views/theories at any time.

[This message has been edited by Mene-Mene (edited June 16, 2007).]

[This message has been edited by Mene-Mene (edited June 17, 2007).]

Briant

Member

Posts: 742
From: Stony Plain, Alberta, Canada
Registered: 01-20-2001
Graphics in C++ is quite a bit more complicated than in BB, mostly because C++ on it's own doesn't do graphics - you have to choose from various libraries and APIs to use, and they can be very different from each other. For basic Microsoft Windows graphics, the "GDI" (graphics device interface) is how to draw basic windows, buttons, bitmaps, etc. "GDI+" gives you a lot more control and features (I think it's a layer on top of DirectX). You can also use DirectX or OpenGL. You can even access the video RAM directly, but nobody does that anymore.

The example in the articles I wrote for this site simply use Windows GDI.

As far as screen savers go, there's really nothing special about them - they are just normal programs with a .scr extension instead of .exe. On thing screen savers SHOULD have though (though not required) is to accept command line parameters:

/c to start in "configure" mode (i.e. let the user change settings, etc.)
/s to start in "normal" mode (i.e. running like a typical screen saver)
/l or /p to start in "preview" mode (i.e. to run in that little monitor on the dialog when you choose which screen saver you want to use)

Once your screen saver app has been placed in the Windows system folder (c:/windows/system32), it will be detected and shown in the screen savers list. Windows will pass it those above command line parameters depending on how it wants you to start, but it's up to you to do it or ignore the request and simply start how you want.

------------------
Brian

"OOP programmers have a lot of class"

Check out this webhost! Fantastic prices, features and support!

Briant

Member

Posts: 742
From: Stony Plain, Alberta, Canada
Registered: 01-20-2001
quote:
This is the new code, still stuck on that error.

I'm not sure how DrawText works, but it looks like you have the parameters in the wrong order. You have x, y, "text" but some samples I found via Google have "text", x, y.

------------------
Brian

"OOP programmers have a lot of class"

Check out this webhost! Fantastic prices, features and support!

Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
Funny thing is, I just thought of that. The old Text function was x,y,$ But this is $,x,y

Alright, past due date, but I'm trying to make this still go on for a belayed FD Present.

Problems:
I've taken care of those errors due to you guy's collective help, and now I've got 2 more.
1. This one has to do with the arrays, i haven't sized them well yet.
2. This one isn't technically a bug, but it just makes a blank screen with nothing changing. I've tried no Back Buffer, no cls, no clip, no both, none of the above, nothing seems to change.

Current Code:


'Screen Saver: Fathers: Pseudo

Graphics 800,600,32,60,Graphics_BackBuffer
SeedRnd MilliSecs()

'Number of words
Global numwords = 3
Global Y = 13
Global X = 8

Type AcWord
Field Together$
Field Letters$[7]
Field NumLetters
Field CurLetter
Field Direction
Field X
Field Y
End Type

Type DoWord
Field Together$
Field Letters$[7]
Field NumLetters
Field CurLetter
Field Direction
Field X
Field Y
End Type

'List of Words
Local Words$[numwords]
Words$[1] = "Loveable"
Words$[2] = "Generous"

AcrossList:TList = CreateList()
DownList:TList = CreateList()

StartMX = MouseX()
StartMY = MouseY()

Repeat
Cls
Flip
If MouseX() <> StartMX
End
EndIf

If MouseY() <> StartMY
End
EndIf

valve = GetChar()
If valve <> 0
End
EndIf

'Across first
For Loop_Var = 2 To 47
'Get Word
RandChosen = Rnd(1,numwords)
A:AcWord = New AcWord
A.Together$ = Words$(RandChosen)

A.NumLetters = Len(A.Together$)
For LoopVar = 1 To (2) 'Needs to be num of letters.
A.Letters$[LoopVar] = Left(Word$,LoopVar)
A.Letters$[LoopVar] = Right(A.Letters$[LoopVar],1)
Next
ListAddLast AcrossList, A
A.Y = Y
Y = Y + 13
Next
'Do Stuff
For Ac:AcWord = EachIn AcrossList
DrawText Ac.Letters$[Ac.CurLetter],Ac.X,Ac.Y
Ac.X = Ac.X + 8
Next

'Down Second
For Loop_Var = 2 To 50
'Get Word
RandChosen = Rnd(0,numwords)
D oWord = New DoWord
D.Together$ = Words$(RandChosen)

D.NumLetters = Len(D.Together$)
For LoopVar = 1 To (2) 'Needs to be num of letters
D.Letters$[LoopVar] = Left(Word$,LoopVar)
D.Letters$[LoopVar] = Right(D.Letters$[LoopVar],1)
Next
ListAddLast DownList, D
D.X = X
X = X + 16
Next
';;Do Stuff
For Do oWord = EachIn DownList
DrawText Do.Letters$[Do.CurLetter],Do.X,Do.Y
Do.Y = Do.Y + 13
Next
X = 0
Y = 0
Forever



[This message has been edited by Mene-Mene (edited June 17, 2007).]

[This message has been edited by Mene-Mene (edited June 17, 2007).]

[This message has been edited by Mene-Mene (edited June 17, 2007).]

Briant

Member

Posts: 742
From: Stony Plain, Alberta, Canada
Registered: 01-20-2001
Altering example I found on the website, try this:



Graphics 800,600,32

; Set drawing operations for double buffering
SetBuffer BackBuffer()

... ; all your current pre-loop code here

Repeat

Cls ; clear the screen

... ; all your current loop code here

Flip ; flip the image into view and clear the back buffer
Forever

Note especially the Flip.

------------------
Brian

"OOP programmers have a lot of class"

Check out this webhost! Fantastic prices, features and support!

Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
I tried that, and I'm pretty sure it crashed my computer, it may be a loop leak. I'll look for the time where a similar problem occured, I think it had to do with either WoB or my programming challenge game.

------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto

I reserve the full right to change my views/theories at any time.